With direct monitoring on, the interface will pass the signal directly to the output. Those signal(s) you do not want to hear from SONAR back at you, so not only do you want input echo off, but also mute those tracks in some cases. Check levels first, but SONAR WILL record an armed and muted track.
You may need to nudge the audio after the fact and/or adjust manual buffer offset, but try the above first.
The direct monitoring knob should adjust how much signal from the inputs is coming out, and may only go through headphones on some interfaces, so check the user manual on recommended usage.