Depends on volume. Nothing wrong with going to sleep with music, as long as it is not loud. If you can hear the music from several feet away, it is probably too loud.
Hearing loss. In the past few years there has been a dramatic increase in the number of children and young adults with hearing loss. Headphones and earbuds may be responsible for this increase. Sleeping with headphones on increases the amount of time the ears are exposed to potentially loud sounds, leading to damage.