It can also happen when a dog has a food allergy, take him/her to a vet and they can tell you for sure. Skin issues are not something to take lightly it can be as simple as a reaction or has bad as mange.
That happened to a dog I know when it was given a flea medicine. It has an alergic reaction.
It sounds like bugs to me that are making the skin getting infected however check this website, scroll down and you will find a long list of skin symptoms, idagnosis and treatment for dogs