In cases like this the audio interface can be the culprit. It uses buffers to store data and then use it. Think of it like a water heater. It holds the data and then uses it so the software doesn't stall. The smaller the buffer the less the latency. This is dependent on the capability of the computer, the software drivers and the computer.
If the computer isn't up to the task, simply record both a midi and an audio track without the soft synth. Then add the midi to the soft synth. You can use the audio track to line up the printed midi track if necessary.
Another thing to check is the monitoring of your interface. If you can't directly monitor try to record with the monitor button disengaged. Guitar can usually be heard without the need to monitor it. Have more than a few channels on your interface? Go into the interface front end and disengage all unused channels. This will make things slightly faster. Good Luck!
If none of that works come back round' and we'll see what else can be done.