Headphones are safer for your ears.

The myth here is that since earbuds go inside your ear canal and headphones rest outside, headphones are safer for your ears than earbuds. This isn’t true. Either of these can be harmful and ultimately depend on your usage.
The ENT Specialists say that extended listening at high volumes can negatively impact your ears, regardless of your device.