Dogs usually dig for three reasons: they're hot; they're after something or their bored. Labradors, Goldens and heavy-coated dogs will dig in shaded areas that tend to be cool (also in areas that collect water). Terriers and "ground" dogs will dig after mice, rats, moles, bugs, etc. in any area of the yard. Almost any other dog digs to alleviate boredom (please see Chewing and proper methods to divert this problem). Digging is a self-rewarding exercise (that means your dog will continue the behavior even if you disapprove). Some dogs are so obsessed with digging that, even though they have been punished, they are willing to accept the punishment for the satisfaction that is gained (digging to a dog can be like cigarette smoking to a human).
To stop the digging it is best to find the cause of the problem and provide an alternative to re-landscaping the yard.
If your dog is digging because of the heat, try a baby pool filled with water and placed in the shade. (If your dog hates water, wet sand can be substituted).
If your dog is after bugs or vermin, treat the yard with insecticides designed to eliminate the problem. (Make sure you don't poison your dog in the process! Read the label directions).
If your dog is bored, consider providing interesting chew toys or a sandbox ("kiddie pools" work great) to dig in. Make sure the sandbox is deep enough for your dog and bury toys for your dog to find. The best thing about sand is that the holes your dog digs will refill, thereby providing hours of digging entertainment and one really tired dog!
If you don't want to actually create a sandbox for your dog you can always set aside an area in your yard that the dog can dig. Find a spot in your yard that you can designate as your dog's own digging hole. Bury one of his or her favorite toys in the hole and encourage them to dig it out. Anytime you find them digging where they shouldn't, take them to their digging hole and say, "dig".
If your dog is one who seems to gravitate towards flowerbeds it is due to new-turned dirt (flower beds, potted plants, etc) attracts all dogs because of the ease of digging. If you have a dog that is hot (see above), try to provide adequate shade or a baby pool. Also consider fencing the area or treating the ground with a pet deterrent (there are several on the market - follow the directions). Also, don't leave your dog unattended in the yard for long periods of time with nothing to do - boredom will definitely be a factor!
If you dog digs under a fence and is getting out. Digging to escape confinement is a very difficult habit to break, especially since the act of digging is not the real reason for the behavior. You may want to consider Invisible Fencing because it is not something your dog can dig under or climb over. Is your pet spayed or neutered? Your pet may be roaming the neighborhood because of a drive to breed so consider neutering or spaying your pet. Is your pet chasing cars, people, horses, etc.? Is he/she playing with the dog next door? Try to determine the exact cause of the behavior and consult a trainer for expert advice.
One thing you can do with the holes already dug by your dog is to pick up the piles of feces in your yard and bury them in the holes. Unless your dog suffers from coprophagia (feces eating) he should leave the hole alone. This won't solve your digging problem. It should however get your dog to leave that particular hole alone and it will take some of the fun out of the digging process for your dog.