Thanks for your query.Based on the facts that you have posted it appears that you have sustaine injury
to your frenulum
while masturbating and having pain since last one week.
Please take antibiotic orally and topical antibiotic
ointment for local application twice daily. Visit your family physician to get prescription of the medicines.
Observe proper personal hygiene and clean the genitals twice with warm water.
Avoid any sexual activity till it heals up completely .This will help in healing and speedy recovery.