The main thing is don't listen to people who say everyone needs the hardest mattress possible. That's a myth. If a mattress is too firm, your spine doesn't get proper support in its natural curves, and your back just gets tense over the night. Same goes for a mattress that's too soft - where you sink in - that's also bad news. Pain after sleep often happens precisely because your spine's in the wrong position at night.
You need to pick firmness based on your weight and how you usually sleep. If you sleep on your side, you need a medium-firm mattress so your shoulder and hip sink in a bit, but your lower back stays straight. People who sleep on their back usually go for medium-firm or firm mattresses. Sleeping on your stomach isn't great, but if you're used to it, you need something firmer. Ideally, before you buy, lie on the mattress in the store for at least fifteen minutes or so, in whatever position you actually sleep in.
Also pay attention to what the mattress is made of. Spring mattresses (especially ones with independent springs) hold their shape well and last forever. Foam or latex are softer, but they can sag over time. And don't forget about the bed base - even a perfect mattress won't help if it's on a sagging or uneven foundation. If the pain hasn't gone away after a month of using a new mattress, you should probably see a doctor - the problem might be something else.