Thanks for your query.Based on the facts that you have posted it appears that you have developed staphylococcal infection
of hair follicle(Boil) at the base of the penis.
Please take some antibiotics like Doxycycline twice daily along with anti inflammatory drug like Diclofenac
for a week.
It should get cured .Get prescription of these drugs from your family Physician. However if problem persists even after taking antibiotics you may need to get it incised and pus to be drained.