Headaches and loud noises don't go well together. Sound hypersensitivity, also termed phonophobia, affects around 70-80% of people who suffer from migraines (via Internal Medicine). People who are vulnerable to migraine headaches tend to perceive loud noises as more intrusive and discomforting than others. Loud or prolonged sounds can also prompt and worsen a migraine headache. And unfortunately, noises like music, air conditioners, nearby traffic, or the hum of background chatter are often part and parcel of working in a busy office (per the BBC).
You can't always avoid being in a noisy place. But if you notice the symptoms of a migraine creeping up on you, it may help to find somewhere quiet to retreat to, recommends Migraine Again. If you're highly susceptible to migraines, you could speak to your employer about working in a quieter part of the office, or having a private space where you can recover if a migraine were to strike. It can also help to carry some earplugs or noise-canceling earphones in your bag.
Although cutting out noise may provide immediate relief, it could be making your phonophobia worse in the long-term, say researchers (via The Journal of Headache and Pain). Gradual exposure to noise, also termed desensitization, has been suggested as an effective long-term strategy for coping with noise triggers.