Dogs may eat grass when they have worms, as grass eating is an instinctive attempt to remove intestinal parasites by inducing vomiting. However, grass is not an effective treatment for worms, and proper veterinary care is recommended.
Why Do Dogs Eat Grass? Written by Hilary Parker.There are a variety of reasons your dog might be grazing on your lawn. Some people propose that dogs might turn to eating grass when they dont feel well as a way to make themselves vomit, and then feel better.

Myth #1: Dogs Eat Grass Only When They Are SickMyth #2: Eating Grass Always Leads To VomitingWhy Do Dogs Eat Grass? So, you just caught your dog munching on grass like theyre trying...

Why Do Dogs Eat Grass?When to Be Concerned About a Dog Eating GrassThe question of whether dogs eat grass to throw up or whether they vomit simply because...

One theory is that dogs eat grass when theyre feeling sick, since the behavior is sometimes followed by vomiting . But its not certain whether dogs eat grass when theyre feeling sick or if they get sick from eating grass kind of like a chicken-or-egg scenario.
In the grass-eating dog population they found that it was the younger dogs who ate grass most frequently and they were less likely to appear sick before or to vomit afterward.