Take over-the-counter pain medications first. A simple over-the-counter anti-inflammatory medication can usually take the edge off most backaches. Follow the instructions on the label, and take it as directed when your back starts acting up. If it isn't enough, consider paying a visit to your doctor.
Lay down and lift your legs as if you were sitting if your back hurts. This comfortable position reduces stress from the back more than other sitting positions. That said, choose any position that makes you feel comfortable, though you do want to avoid twisting your spine.
Believe it or not, sleep is actually an essential part of healing from back injuries. Your body does most of its repair work at night when you are relaxed and sleeping and can dedicate all of your energy to healing. If you are experiencing chronic back pain, then good sleep is as important as good medicine.
Stopping back pain can be achieved by having good posture early on in life. Sitting up straight in your computer chair can help greatly if you spend a lot of time in it. If you're always slouching, you can develop back pain later in your life and so it's best to keep a good posture early on.