Dropping expletives may not only be an expression of agony, but also a means to alleviate it. Scientific American reports that although cursing is notoriously decried in the public debate, swearing may serve an important function in relieving pain.

Swearing is such a common response to pain that there has to be an underlying reason why we do it,

A study measured how long college students could keep their hands immersed in cold water. During the chilly exercise, they could repeat an expletive of their choice or chant a neutral word. When swearing, the 67 student volunteers reported less pain and on average endured about 40 seconds longer. How swearing achieves its physical effects is unclear, but the researchers speculate that brain circuitry linked to emotion is involved. Earlier studies have shown that unlike normal language, which relies on the outer few millimeters in the left hemisphere of the brain, expletives hinge on evolutionarily ancient structures buried deep inside the right half like the amygdala, an almond-shaped group of neurons that can trigger a fight-or-flight response in which our heart rate climbs and we become less sensitive to pain.

Source: Scientific American - Why the #$%! Do We Swear? For Pain Relief