It's a sync issue between the internal clock and whichever sound device you're using to generate the metronome notes. There are a few solutions:
1) Try a different audio device for the metronome. (In Sonar 4, though I assume 5 is the same,) under Project Options, on the Metronome tab, try each of the different options for "Output".
2) Use a midi metronome instead of audio, or vice-versa (depends on your setup.) On the same tab as above, choose the appropriate option. In my experience, you'll have the best luck using an audio metronome, and setting the output device to the same unit that you're using to record.
3) Use a count-in (again, same settings page) .. You'll miss the first beat of the count-in too, but everything will start right on beat 1 of your actual project.