The most reliable way to keep a dog from eating potting soil is to limit its access by placing the plants on high shelves or in areas the dog cannot access. If this is not feasible, try to make the potting soil taste bad by covering it with a substance the dog finds unappetizing, such as a bitter apple spray or citrus scent.
In addition to commercial no-chew sprays, pepper, mustard seeds and chili powder can help. Bitter orange oil or ground orange peels may deter some dogs. These may need to be reapplied after watering.
Dogs may be motivated to eat potting soil for several reasons, so sometimes managing the underlying cause can stop the problem. If your dog has a nutritional deficiency, it may instinctively try to correct that by eating soil. Your veterinarian can help you determine if your dog's diet is meeting its nutritional needs.
Dogs may also eat soil out of boredom. Make sure your dog is getting plenty of exercise and has appropriate outlets for chewing, such as toys and long-lasting chews.
In some cases, dogs may feel sick and eat the soil to trigger vomiting. If this only happens occasionally, it may not be a cause for concern. However, if your dog is frequently eating soil and then vomiting, consult your veterinarian for advice.