The term for a dog eating it's own feces is coprophagia. It has quite a few meanings, and causes, depending who you talk to, but the most interesting one I've read about is the possibility of the dog having a shortage of one of the B vitamins, biotin to be exact. I personally think they just love eating poop, but that's probably not right! It is not supposed to be anything to get worried about, it's just disgusting, to us.
Vet's have a product called "Forbid" which you can sprinkle on the food. it helps 50% of the time. I might try it. Ive known some to use tobasco sauce too, nothing like hot poop to break the habit LOL, tiny bit obviously
Even with a baby gate up to the litter box, my dogs still find there way to "the snack shack" as we call it. Our vet doesn't seem concerned about it. She says "it's just a dog thing" I dunno. But I worry about worms and other diseases they could get. So far so good....but I still worry.
I know I've posted it somewhere else in here, on another thread, but I've found the most effective, safest, and cheapest way to treat the poop-eating affliction. Crushed Pineapple. Completely safe and healthy to give to your dog, and they absolutely love it. The enzymes in pineapple give the poop a taste that is too unpleasant to consume. I've never seen a dog refuse pineapple, and I've never seen a dog eat their poop after eating pineapple. My female used to eat her feces, until I started the pineapple thing. My male just loves pineapple and doesn't want to be left out of what he considers a treat. He's 8 1/2 pounds, and she's 12, and I give them one smaller can of pineapple (the ones that look like tuna fish cans.)