I would put some neosporen on it... It will get rid of any infection and will also make the pain go away. The problem though is that your dog will try to lick it off. I'm not sure how you can prevent that other than watching him/her or putting on of those things on his/her head
It will usually clear up pretty quickly once you clear up whatever is causing the diarrhea as with us. You would have to speak to your vet about anything you were wanting to put on your pup. You might ask them about getting some derma vet or something since that clears up a lot of things quickly if they have been having that much trouble. If it's that bad then be sure to watch carefully for a prolapse as well. Hope your baby is all better very soon.