Knee pain can have many causes, ranging from sudden injury to wear-and-tear in the joint. The specifics of the pain, like whether it feels dull and achy or sharp and burning, and how long it lasts can give clues to what is causing the problem.
Pain on the inside of your knee when straightening it could be due to an imbalance in the inner hamstring muscle, specifically the semitendinosus muscle. Try the inner hamstring stretch to see if this helps. Pain on the front of your knee when straightening it is more often due to a problem with the front part of your meniscus or the infrapatellar fat pad. These are fluid-filled sacs that allow tendons, ligaments and muscles to glide easily on boney areas of the knee. If you do a lot of activities that require repetitive knee movement, or if you are overweight, you may develop inflammation of these sacs, which can cause pain when straightening your leg.
Your doctor can advise you on treatment options depending on what is causing the pain in your knee. This might include ice therapy, taking over-the-counter painkillers such as ibuprofen and strengthening exercises. It might also involve physiotherapy or a referral to a specialist. You might be advised to try a knee brace or surgery. Depending on the condition that is causing your knee pain, your doctor might also prescribe stronger painkillers such as codeine. However, this is usually only used if other treatments don't work.