Trauma. Sounds as though you have had some friction to the penis. This is common with both masturbation and with vaginal intercourse. Try an ice pack or cold pack for a few minutes and observe. If this is persistent, get seen and find out if there is an allergic reaction, infection or other issue. Poison oak and ivy are common to get on the penis. This will need specific treatment by a doctor.
Posthitis. Most often this is a fungal inflammation of the foreskin, or posthitis. This is very common in uncircumcised diabetics. Often the first line of treatment is the use of topical antifungal creams. You should present to your urologist if recurrence or an inability to retract or reduce the foreskin.