Can I transfer or sync purchased as well as non-purchased songs from my iPhone to my computer? So, I wiped my drive clean on my MacBook and reinstalled the OS. Happily the best of my music was safe on my iPhone and I figured it would easily flow back to my iTunes library.

Not so happily, I can't seem to figure out how to get this music, which is mine, to the laptop, which is mine, from the iphone, which is mine.  

I don't want to jailbreak my phone just for this one task, I'm running iOS 4.2.1 on an iPhone 3G and my MacBook 5,1 runs OS X version 10.6.5.

I would like my music back.  How to do this?
Things you've purchased off the iTunes Store can be transferred off your iPhone by right clicking on your iPhone in iTunes and choosing 'Transfer Purchases'. You might need to Authorise your computer first by clicking the Store Menu, and then choosing Authorise This Computer. 

For your non-iTunes Store content I'd recommend Senuti (read it backwards!) which lets you copy music from your iPhone or iPad back to your mac. Senuti costs $18, but there's a trial version, which can transfer up to 1000 songs.

Neither of these require a jailbreak.