This is a very common problem in the increasingly sedentary culture in which we live; and it can actually be amplified by incorrect weight training practices. On the most basic level, what happens is that your chest muscles become too tight and your back muscles become too stretched, thus your shoulders are pulled inward by your tightened chest muscles...
...One major cause of this is too much sitting in a hunched over position, like right now as you sit, (or stand) slouched and hovering over your laptop, desktop or mobile device. As you can imagine, this position activates the chest muscles and stretches out the back muscles. This becomes a problem when you do this consistently for long periods of time. The problem because exaggerated by doing a disproportionate number of weight lifting exercises that involve pushing muscles (i.e. chest, triceps, shoulder) compared to exercises that involved the pulling muscles (i.e. back, biceps, rear deltoids).
The fix?
- Stretch your chest and the other pulling muscles (see "shoulder dislocates" link, and also look at the "chest stretches" link)
- Do more pulling exercises (see "Weight Lifting" link below for general weight training info; the site also has an exercise database)
- Take frequent breaks (e.g. every 15-20 minutes) when sitting down for long periods of time and do a little stretching if possible; otherwise, just walk around or stand up for at least a few seconds. This may seem useless, but due to the components of the Law of Repetitive Motion, adhering to this advice will greatly reduce the negative impacts of extended periods of slouching by decreasing the amount of time you are in a bad postural position
- Stop slouching over so much! What are you, the Hunchback of Notre Dame?! ;-P
- See a qualified physical therapist, or similar type of doctor
Boxing. Abdominal workouts also aid in strengthening postural problems.
Good posture is mainly a result of keeping your chest up, which is done by the lower back (lumbar or erector spinae) muscles. Work them with deadlifts, good mornings and weighted hyperextensions. Shrugs and deltoid raises, and incline press.