Do you do any warming up before you start playing? If not, then you need to start doing fretboard exercises before you do any serious playing. There was a time a few years ago when I didn't warm up at all, and after an hour or so I would get a pain in between my index and middle fingers. I never get any serious pains anymore because I spend about five minutes each session going through a basic exercise before tackling the music.
A good way to warm up is to do a repeated pattern, for example, playing the 12,13,14,15 frets up the neck with your respective 1,2,3,4th fingers on the sixth string and then repeating the pattern on the other five strings, then going down one position to the 11th fret and so on all the way down the neck, and then back up until you get back to the 12th position. Play naturally and do not try and go fast or play hard, just let your fingers gradually increase in speed. Starting at the 12th position also eases your fingers into the motions without dealing with stretching..
Yeah it sounds silly, and many brush off the idea of warming up.. But there have been many people who have cut their playing short due to tendonitis and all the other evils of guitarists. Warming up can also help to improve your playing as well..
Experiencing minor, little pains from time to time is OK. Just make sure to take a break here and there and shake the tension out of your hands.