You don't even need to connect the phone. Once you sign into iTunes on the computer you can go to the Purchased section and download your music directly. Of course, depending on your internet speed the phone transfer may be faster.
Always be cautions about what choices you make when connecting an iOS device to a computer and iTunes the first time. You 'Do Not' want to choose to reformat the iOS device as new. Just say no.
If iTunes does not ask you if you want to transfer purchases after connecting the iPhone you should be able to find the option under the Files menu. Might be in a submenu. I don't remember off the top of my head.
Note: This is in response to the previous post about transferring music already on an iPhone to the computer. Not the original question about transferring music from the computer to the iPad or other iOS device.