Thanks for your query,based on the facts that you have posted it appears that you have either staphylococcal infection
of hair follicle or infected sebaceous cyst
on base of the penis .
Please take You need to take broad spectrum antibiotic like Cefexine along with anti inflammatory drug like Diclofenac
Observe proper personal hygiene by washing your genitals with warm water twice daily.