For many people, this can be something that occurs when you first adopt a dog from a shelter where they are not fed/exercised/bored. This is a term for when dogs eat their own waste.
Luckily this can be reversed in most cases very easily. If not, and even if it can be, it is probably best to take your dog to the vet to ensure that they are getting all their proper nutrients and do not have parasites.
Exercise, keeping your dog from getting bored and upgrading their food to better, nutrient rich food can help.
Here is an article that explains this more in depth. Hopefully if your dog suffers from this, a trip to the vet and a change in their diet/exercise regime can help solve the problem.