If you have purchased stuff from the Apple iTunes Store you can go into iTunes and use the "File->Transfer Purchases from..." to copy them back to your computer.
However I suspect you have non iTunes Store items (e.g. a CD you owned, which you recorded to MP3 files and stored in iTunes). Unfortunately these are MUCH more difficult to restore from an iPhone/iPod.
Basically the iPhone/iPod isn't designed to be a back up device so it's not easy to restore from it. It's supposed to be mostly a one way computer->iPhone type device with the master copy on the computer. Now the main reason for this is probably to stop you sharing songs with your mates (E.g. So you can't borrow someone's iPhone, plug it into your computer, and steal their songs to save you buying them). You really should back up your computer separately.
So what can you do? Well there are 3rd party applications that allow you to take songs and content off the iPhone. I've had varying experience with them and basically never found one that worked perfectly. Though it was a while since I tried one out.
This website has great explanation of how they work and mini reviews of some of the options available:
http://www.ilounge.com/index.php/articl ... -computer/However this changes a lot so might be worth googling "how to copy songs from iphone to computer" in case there are any better options.