It also helps if you can slow down the music to replay the tricky bits. There are a number of programs that will do this on your computer. The ones you pay for can usually slow down the music by 100%. Winamp has a plug-in called "slow me down" that will slow the music down by 50% and keep it at the same pitch. It is also free.
You'd have to convert the song to MP3 format first. Just one bit of advice; when you convert a song from one of your CDs to MP3 format you'll want to set it to record at the highest bit rate, or highest quality. Otherwise the music becomes a little garbled when you slow it down.
Learning by ear is rather difficult at first, but it gets easier with experience. It also helps you to develop an intuitive feel for how the different parts (melody, harmony, vocal lines) fit together, which helps when you want to write your own material.