I had surgery for a herniated disk years ago largely a result of poor posture at my computer at work, and years of heavy weightlifting using not-so-great form.
It will take time, but here's a couple tips.
Superman pose. Basically exercise you perform, you should be in something of a superman pose, with your chest sticking out and your shoulders square.
If you make a conscious effort to do this, it will help a lot.
Believe it or not, taking a dance class will radically change your posture in a good way...and it comes in handy at weddings and parties when the rest of the tools are doing the macarena.
Lindy Hop is great....or any other ballroom dance.
If you sit at a computer or something, same thing as working out...superman pose. Butt all the way back in your chair with a support for your lower back that keeps you at a slight arch.
Also, a great technique for improving posture and getting rid of various pains naturally is the McKenzie Method:
Hope some of that helps.