The symptoms you had described are probably due to a fungal infection known as Candidiasis or Thrush. A fungus called as Candida Albicans causes it. Here patients usually present with red spots on the head of the penis, irritation, pain on contact and redness. However we cannot completely rule out other possibilities such as:
a) Herpes
b) Gonorrhea
c) Chlamydia
d) Syphilis
I would suggest you to get a complete blood and urine test, patch test, screening test s like HIV, VDRL and consult the dermatologist with these reports. You can use antifungal creams like Candid A twice a day for 1-week .you can also take a few preventive measures such as:
Maintain a good personal hygiene and avoid sharing personal items such as towels. You can also avoid sex during this period and consumption of yeast products. You can also ask your partner to get a screening test. Hope this helps.