22FX has 2 inputs / 2 outputs audio interface. Sonar has no internal track to track routing, everything you record comes from your mixer. So the goal is to route the signal correctly inside mixer.
You have 6 buses: AUX1-2, AUX3-FX and (main mix)LR. You can have any of these 3 pairs as (Sonar) recording input and as monitor (headphones) output. Main output is always (main mix)LR.
To record something while listening something else you should route such way that monitoring is not leaking into recording. For example, you send what you want to record to AUX1-2 (and corresponding button is pressed near USB send) while checking that nothing else goes there. Especially that USB return is not by occasion is also sent to AUX1-2 (either it is sent to LR, or ST3 is not goes to AUX1-2 directly nor throw FX). Monitors (headphones) can be LR then, where required monitoring combination is composed (from USB return and recording sources).
You can check that everything is correct by playing something on USB return and listening on phones. When phones are in AUX1-2 mode you should not hear USB and get correct monitoring mix when in LR mode.
On Sonar side, check that you don to set "Input echo" where you do not want it.
PS. I am n00b, all that is theoretical. After I have found that what you want is not possible on my Behringer, I decided to understand how that can be done on "real" device. For me it looks like 10FX is simpler to use for that purpose, it has "Rec" buttons instead of "AUX1-2" sends level. Not flexible, but "self explaining"