Every true artist is prepared to suffer for his craft. No pain, no gain, right? No, actually, not always.
When it comes to your physical health, suffering does very little for your art. In fact, it generally makes it worse. It's hard to play and practice through pain (not to mention that it's terrible for your long-term health) and it completely distracts you from your efforts anyway. We all like to play hard, but it's best to balance that passion with playing safely as well.
Ideally, you want to avoid health problems altogether. How? Awareness is the first key.
If you're here because you're already feeling pain, you might have landed in this situation because you just weren't paying very good attention to your body. We tend to pick up a guitar for the first time and assume the same positions and habits we've seen others use, mimicking other artists rather than figuring out what works best for us. And the difference can be huge.
Some people press the end of their thumb into the back of the guitar neck while playing. Others wrap their whole thumb around until it's almost resting on top. Which do you do? You may not know off the top of your head because it's just one of those things we do without thinking. Well, it's time to think. One position may be putting severe stress on your wrist, so it's best to take time to play and pay special attention to how you feel physically. Keep in mind that there is no "right" way to do things (although there are recommendations that work for most people) there is only what works and feels best for you.
Follow the natural bends of your body
You want to be as comfortable as possible when you're playing, and that means avoiding any habits that might be bending your joints in ways they don't naturally bend. Let's look at your fingers, for example. If you're pressing so hard on the strings that your top knuckle is bent backward rather than forwards, it's time to adjust your technique.
Similarly, we can assume that the natural state of your wrist is being held straight. Of course, you can't play guitar and keep your wrist entirely straight, but you should adjust yourself (and the length of your guitar strap) so that it's bending as little as possible. Since you do have to bend your body to play, rely on your largest and strongest body parts to bend, rather than the smallest. If your fingers are under strain from being bent, then bend your wrist instead. Then see if you can adjust your style to bend your elbow more to take the strain off your wrist.
Whatever you do, don't push through or ignore pain. A little soreness is ok, even good for you as it means your building strength. But pain means you're tearing yourself down. Stop playing as soon as it comes to that and take a rest. Hopefully, that's all you'll need. If you have any doubts, see a doctor.