The best protection is to avoid exposure to any loud sounds. If that is not an option, wear some form of hearing protection such as earplugs or earmuffs. Under the law, any person exposed to noise over a certain level on the job must have hearing protection available on site. Companies which follow these laws have noise programs that monitor the noise and conduct annual hearing tests on all employees who are routinely exposed to noise.
At home you should have a set of earplugs in your workshop or carry a set of earplugs in your jacket. If you can control the loudness or volume of the noise, your best approach is to turn down the volume.