It can be possible that your dog has a bacterial infection inside the ears or on the skin or a secondary yeast. Also, a buildup can cause an awful smell, hard to eliminate. So, you can consult your vet to see how to prevent and adequately treat these phenomena and stop foul odors on your dog's skin or fur.