If I sit for too long my back starts to hurt. The only way it goes away is if I lie down. What could I do? And what might be the cause?

Usually a disc . Usually a disc issue due to loss of its structural integrity with sitting placing a 4 times body load on the affected disc. You may need to get into better shape to compensate for this by increasing your core strength, possibly more regular exercise & weight control if indicated, better body mechanics in terms of bending & lifting, smoking cessation if this is an issue & otc medication.