Some would say never put on ear-buds while cycling as you want to be able to hear the traffic around you. While I agree that it is dangerous to not be aware of your surroundings on a bicycle, I still listen to music with my earbuds because it makes the experience so much more profound. You have to come up with a compromise.
1. Put your ear buds on before you snap the buckle on your helmet. This way, if an ear bud falls out while you’re riding, the helmet straps prevent them from falling down toward the ground, or worse, into the spokes. I will often take one or both ear buds out if I want to be more aware of my surroundings and since it’s hooked by the helmet strap, I could easily find it and put it back in my ear.
2. Don’t blast the music all the way: You have to find a compromise where the music is loud enough for you to enjoy but it’s not SO loud that you can’t hear the cars or people next to you. This is seriously the most important tip if you are adamant about listening to music.