In EU countries, the law protecting people at work from high sound levels is based on the 1986 EU Council Directive 86/188. Each EU country has translated this directive into its own law. In the UK this is done by the Noise at Work Regulations (1989).
This law is based mainly on the concept of a daily noise "exposure". A loud sound for a short period, or a not so loud sound for a longer period, can both give the same exposure. If the sound level is steady and the working day is eight hours, the exposure is numerically the same as the sound level - for example, a production-line worker, on an eight-hour shift, in a factory with a steady noise level of 95dB(A), would have a daily exposure of 95dB. If the sound level varies, the exposure must be measured with an integrating sound level meter.
There are two levels of exposure at which specific action must be taken, the first action level of 85dB and the second action level of 90dB. When the first action level is reached, employers must give their employees information and training, and offer them ear protection (for example, earplugs) but the employees don’t have to wear the protection if they don’t want to. However when the second action level is reached, the employees are breaking the law if they don’t wear the ear protection; and the employer must also do what they can to reduce the noise level.
Of course some sounds, such as close gunfire, can cause damage almost instantaneously, so the regulations also limit the instantaneous maximum sound that people can be exposed to. Luckily music on earphones is extremely unlikely to reach this level1, although it is not impossible under fault conditions which could apply a high voltage to the earphones.
Most developed countries have some form of law to control sound levels at work, usually based on an exposure limit of 85dB or 90dB. In the US, the OSHA sets a 90dB limit.
Those with responsibility for people exposed to high sound levels should check on the law in their own country. Even within the EU there are variations - for example in most EU countries employers have to provide audiometry to people with a high noise exposure.
1A sound pressure of 200 Pascals, equivalent to the peak level of a pure tone whose RMS level is 137dB.