Medical term for causing pain to one part of body to relieve chronic pain elsewhere

I believe this act is known by several terms: self-harm, self-injury, and self-mutilation. People who inflict injuries onto themselves are looking to relieve pain, be it psychological or physical, from a pre-existing one. The injury releases endorphins to the brain and acts like a painkiller.

Endorphins are neurotransmitters that act similarly to morphine and reduce the amount of pain we experience when we are hurt. Joggers often report experiencing a "runners high" when reaching a physically stressful period. This "high" is the physiological reaction to the release of endorphins - the masking of pain by a substance that mimics morphine. When people self-injure, the same process takes place. Endorphins are released which limit or block the amount of physical pain that's experienced. Sometimes people who intentionally hurt themselves will even say that they felt a "rush" or "high" from the act. Given the role of endorphins, this makes perfect sense.

Perhaps the OP was remembering a scene from House, the TV series, where Dr Gregory House cuts himself because he has no access to vicodin.

Cameron: House, these cuts are straight, in a row. You did this on purpose.
House: Cutting releases endorphins, endorphins relieve pain.
You going to get me some pills?

Cameron: No.
House: Well, then you can leave.

House M.D, season 3, episode 10


To stimulate blood-flow to promote healing, Counter-irritants are sometimes used.

In traditional medicine, Mustard baths restored the circulation after feet had 'lost all feeling.'

Chilblains are treated with heparin and salicilates -vasodilator and mild counter-irritant.

Some treatments for leg ulcers are similar.