There are a couple possibilities. In either case, you should see your doctor.
If your pain goes away gradually when you sit, you may have spinal stenosis. Spinal stenosis is a condition in which the spinal canal or openings around the spinal nerves narrows. The sitting position opens the space around the nerves, relieving pressure. Spinal stenosis can be caused by disc problems, bone spurs, infection, or tumors. It is more common in people over 60, but some people are born with narrower spinal canals and may develop the problem younger.
If the pain goes away without sitting down, the problem may be a lack of blood supply to your working muscles. This condition is called intermittent claudication. The aching, cramping or tiredness caused by walking go away in less than five minutes of rest. The lack of blood supply is usually caused by hardening in the blood vessels of the legs, which is called arteriosclerosis.