I would definitely recommend that you go to see your primary care doctor
about this. Any persistent pain in a joint like this needs to be evaluated. Your doctor should be able to help figure out what is likely to be going on and also make recommendations about what you should do in terms of treatment.
Given the locking sensations and popping phenomenon that you are experiencing, one likely possibility here is something called patello femoral pain syndrome. This is a condition in which the cartilage on the undersurface of the patella (knee cap) degenerates. This causes the patella not to track well over the underlying bone, causing the symptoms of pain and popping. The condition can generally be treated fairly effectively with a combination of anti inflammatory medications, good shoes, and targeted exercises to strengthen and balance different groups of muscles in the legs.
In addition to this condition, the doctor will also evaluate for other potential conditions, including injuries to the various ligaments that surround the knee.
Based on what they discover, in addition to the types of treatments I mention above, they also may recommend additional testing (such as an MRI
of the knee) or referral to a specialist. Again, please see your doctor soon.