You should never wear headphones when you ride, especially ones that block out the sound of traffic.
I like to wear headphones but I find that the cord pulls down and irritates me. Of course a lot of things irritate me, but I digress.
To solve this problem, I zip tie a small safety pin to the cord. I can then attach this to my shirt (jersey) and they ear buds stay in my ear without any problem.
I also use a twist tie to tie up the extra cord so that it doesn't whip around in the wind (and irritate me).
Finally, I put my MP3 player in a plastic Ziploc bag so that no sweat can get into it.
For the past few years I have been using Sony headphones, but recently they have been failing after only a few months use. (I assume it is because sweat is getting into them and corroding the wire). I just bought a pair of lower end audio-technica headphones and the sound isn't as good as the Sony ones but I want to see how long they last before getting nicer ones. I assume that the more expensive ones will have better sound quality.