You can't transfer music from iPhone to iTunes. You can only transfer music iTunes to iPhone. This is to prevent music from being pirated easily.
If you purchased the music directly from iTunes, all you need to do is make certain that you have iTunes signed on to the same Apple ID and download your purchases directly. You won't be charged if you already purchased via your iPhone. In iTunes go to Store > Check for available downloads.
Not sure about the legality of this, but there exist ways to transfer non-purchased songs from iPhone to iTunes. If you are on Mac, try Senuti (iTunes spelled backwards, mind the pun). If you are on Windows, try CopyTrans.