The reason you feel good on painkillers is because they mimic your body's endorphins. When you are in pain, your body releases endorphins to make you feel better; your very own morphine! When you take morphine or another morphine-like drug (they're called opioids) they may make you feel euphoric (really happy and up) as well as relieve your pain. As you can imagine, this is also why they are abused by many people. Feeling euphoric when you take opioids doesn't mean you're depressed. If you feel sad or hopeless most days, can't enjoy things that you used to like, are sleeping and eating more or less than is normal for you, and if you've felt like this for at least wo weeks, you may be depressed, and you should see your doctor.
Pharmacology for Nurses by Adams, Josephson and Holland