Greetings from Brazil.
Although I am a physician, my area is cardiology (quite different from this hand/orthopaedics problem), so what I say below is not meant to be a substitute for professional medical advice.
You should never feel pain anywhere when you play (at least, physical pain...
Two problems commonly affect pianists: carpal tunnel syndrome and tendonitis. Both are related to what we call repetitive strain injury, an ailment that affects professionals who have to make repetitive similar motions in their work. Typists, heavy computer users, and musicians (instrumentists) alike, among others.
To avoid them, good habits and proper technique is necessary, things like poise, proper posture, hand and wrist position, etc, are in order.
You should also always play very relaxed. There are even some that say that in the long run it is better not to practice at all if you are not relaxed, than to play in a tense mood or manner.
Something also that helps is to take frequent breaks from practice, like 30 seconds every five minutes AND 15 minutes for every 45 minutes you play. I would keep practice times under 3 hours a day.
If you cannot seem to play more relaxed, try taking a break from that particular material you are studying at that time and try something less complex for a while, then go back to the former.
Most importantly, if you start feeling pain, it is very important to take a break until you do not anymore. Consider if you have had enough practice for the day. Another way to do this is to practice hands separate and alternate hands when you feel any least bit or any hint of discomfort.
If the pain becomes daily or habitual, you should definitely see a doctor, probably an orthopaedic surgeon who is skilled in hand surgery. Here in Brazil they are called "hand surgeons". For tendonitis, he will mostly make recommendations that are similar (but more thorough) to what I have told you here, plus refer you to a physical therapist to mitigate the pain. Do not resort to pain killers because their chronic use can be dangerous. It is also necessary to evaluate the presence (or absence) of carpal tunnel syndrome, which is the compression of a particular nerve that runs through our forearm that can also cause numbness and sometimes pain. Surgery can fix that.
I hope I have helped, and there is no need to be scared by what I said, as those problems can easily be controlled/mitigated by proper practice habits, and in the case of carpal tunnel syndrome the surgery is fairly simple and can usually be done in an ambulatory setting (outpatient).
To summarze, no internet info can substitute for one-to-one profesional medical advice, because a doctor can discuss problems that are specific to you, to your practice routine and habits, and also order proper exams to thoroughly evaluate any other conditions if present.
A good piano teacher should also be ableto provide you with information on good practice habits and preventive measures for repetitive strain injuries. This is really an area where a stitch in time saves nine.