If you take a pain killer orally, like a pill or liquid, then it goes into your blood stream and goes everywhere, not just the place where the pain is. Same if you get the medicine IV, or if it’s a pain patch that delivers medicine.
Pain medicine can work in different ways. It can reduce the transmission of pain so that your brain does not get the signal of pain. Some pain meds reduce inflammation or relax muscles, which can help with certain types of pain.
You don’t “feel” the drug working in other parts of your body, because other parts aren’t in pain. Although, some very strong drugs you will feel all over. For instance, strong muscle relaxers will make you feel more more relaxed all over, and reduce the pain in the area that had been in pain.