Thanks for your query.Based on the facts that you have posted it appears that you have what developed infection of Glans Penis
called as Ballanitis.due to vigorous masturbation
Please take broad spectrum antibiotics and anti inflammatory medication along with topical antibiotic
ointment for local application.
Get prescription of the drugs from your family Physician,
Ensure to clean your genitals with warm water twice daily and avoid masturbation till it heals completely.