Every situation is different - ask your health and safety coordinator if listening to music is allowed in your workplace. There are important safety concerns to consider:
A music player is not a substitute for proper hearing protection. If you are exposed to hazardous noise (on or off the job), it's extremely important that you consistently wear properly fitted and adequate hearing protectors.
A music player should not have loud outputs. Some music players have uncontrolled volume levels. The last thing you want to do is risk your hearing by listening to loud music for extended periods of time.
Music players can cause distractions and pose a safety risk. Whether you're out for a walk or run in your local neighborhood, or on a worksite with moving vehicles and machinery, you need to understand that your ability to hear safety warnings may be compromised if you're distracted or if listening to headphones masks important sounds in your environment.
Take charge of your personal safety both on and off the job. Advice and interpretation from OSHA: OSHA Standard Interpretation, 2019.