This is probably Balanoposthiritis, which occurs most commonly in un-neautered male dogs. Your vet'll probably want to do a full examination, under anesthetic, to make sure there are no foreign bodies in area. A blood test can also rule out tumours and other problems.
Antii-bitotics are sometimes given, along with advice to have the dog neutered. this should cure the problem.
Vets DO charge a lot of money, but you have to be prepared for this if you have a pet. If you're on a low income or not working, contact the PDSA. A private vet may allow you to pay in instalments.