Many years ago, the Samsung Galaxy Note 7 gained notoriety when its batteries caught fire in a series of incidents. Since then, there has been a steady stream of similar, albeit isolated, incidents. However, despite the widespread coverage of battery failures, the vast majority of lithium-ion batteries are safe.
The chemical reaction that takes place inside a lithium-ion cell is complex, but like any battery, there is a negative and a positive electrode. In lithium batteries, the minus is a compound of lithium with carbon, and the plus is cobalt oxide (although many battery manufacturers refuse cobalt). These two compounds cause a reaction that is safe to control and delivers power to your devices. However, when the reaction gets out of control, the headphones melt in the ears. What can change a safe response to an uncontrolled response can be many things: excess heat, physical damage during use, physical damage during manufacture, or use of the wrong charger.
Three basic rules that have kept me safe (so far) when testing dozens and dozens of batteries:
Avoid cheap wall outlet adapters, cords, and chargers. This is your most likely source of problems. Are those chargers you see on Amazon $20 cheaper than the competition? Not worth it. They probably reduced the price by saving on insulation, ditching power management tools, and ignoring the basics of electrical safety. Price alone is not a guarantee of security. Buy from well-known companies and brands.
Then there is the heat. Too much of it can cause all sorts of problems, both in terms of discharge and security. Avoid overheating and keep an eye on the batteries while charging. If your device gets very hot while charging, this could be a sign of problems. Likewise, beware of any swollen, swollen, or otherwise deformed batteries.