You have answer in your question. Your posture correction and pain relief can be done by two ways.
One is by doing exercises and other is by doing some modifications in your work place.
Next Steps
You need to do simple stretches from head to foot twice a day.
You should arrange your laptop or desktop in your eyesight level.
You should sit erect in a back rest chair.
You need to take breaks in between your work for every one hour for just five minutes. Stand for some time, walk around and then sit.
Health Tips
If the pain persists or aggrevates you need to consult a Physician or Physiotherapist or Orthopaedist for further evaluation and treatment.