they affect the brain and they affect Neural pathways, if you have pain in your foot, painkillers do not go to your foot to sort the pain. They go into your brain.
I am not going to go into the nerve pathways from differing parts of the body to the brain because it would be inappropriate in a basically social forum.
Analgesics ( pain killers) can act peripherally ( far away from the brain and at the point of the pain) OR centrally ( as the pain impulses reach the brain which appreciates pain).
When part of your body is injured, special nerve endings send pain messages back to your brain. Painkilling drugs interfere with these messages, either at the site of the injury, in the spinal cord or in the brain itself. Many painkillers are based on one of two naturally occurring drugs: aspirin and opiates.