No one completely understands how pain works. The more we find out the more questions arise. So we'll take a simplified view.
You feel pain in your brain. For example, if you hit your finger with a hammer, the part of your finger that got damaged has nerve endings. These nerve endings feel things like vibration, heat, light touch (from things like a feather) and, of course, big crushing pain (like being hit with a hammer). Different receptors pick up each of these types of sensations. Damaged tissue in your finger also releases chemicals that make those nerve endings register the crushing pain even stronger -- like turning up the volume on a stereo.
A portion of these chemicals are prostaglandins. Cells in the damaged tissue make these chemicals using an enzyme called cyclooxygenase 2 (or COX-2). Because of the prostaglandins, nerve endings involved send a strong signal through nerves in your hand, then the signal goes through your arm, then up your neck and finally into your brain, where your mind deciphers this signal to mean, &qupt;HEY! PAIN!" The prostaglandins contribute just a portion of the total signal for pain, but it is an important one. Additionally, prostaglandins cause the finger to swell (called inflammation) which bathes the tissues in a blood fluid that will protect it and help it to heal.
Aspirin helps reduce pain by sticking to the COX-2 enzymes, preventing them from making prostaglandins; it's like a lock you put on your bicycle. Your bike won't move with the lock on; COX-2 can't work with aspirin stuck in it.
By taking aspirin, you don't stop the problem causing the pain -- for example tight muscles in your scalp that are causing a headache, or the hammer-damaged finger -- but aspirin does "lower the volume" of the pain signals that travel through your nerves to your brain.