There are a number of bike set-up factors that may result in the pain you are experiencing, including incorrect seat height, seat position, cleat position and reach distance.

I would have a look at where your knee is positioned having a pedal at 3 o'clock. The front of the knee should be close to the centre of your cleat position. If it is not I would play around with one of the factors mentioned above until it feels right.

Generally speaking you should not have to get off an adjust your seat height during a ride. Your mountain bike seat height should be approximately 1-2cm lower than your road seat height otherwise you are not allowing your body enough extra mobility to deal with the extra stresses that mountain biking requires. I know it probably feels more comfortable having your seat up high on the climbs, but if you lean slightly forward when climbing you will unload the back wheel just a much.