You should definitely go to see your primary care doctor
about this as soon as possible. There are several possibilities that need to be ruled out, and your doctor can perform the necessary examinations and tests to reach a diagnosis.
First of all, I think the possibility of a sexually transmitted infection is high on the list, even though you say you haven't had sex in a while. Sometimes the symptoms of a sexually transmitted infection can take a while to develop, and these symptoms typically are just like the symptoms you are describing - itching and stinging, especially with urination. A simple urine test will be able to rule out the common sexually transmitted infections, and there are excellent antibiotics to treat the infections that your doctor can prescribe for you.
Also on the list, but much lower down, is the possibility of a urine infection. Urine infections rarely occur in otherwise healthy men, but they can sometimes happen. When your doctor looks for sexually transmitted infections, they will also be able to look for a urine infection.
Finally, if you are uncircumcised, it is possible to get a condition called balanitis, which is an inflammation of the tip of the penis under the foreskin.
Start by seeing your primary care doctor as soon as possible.