There are two reasons that dogs dig. One reason is that your dog may be too hot or too cool. Digging a hole and lying in it acts as sort of a homemade self-regulating temperature unit. Your poor dog cannot shed clothes and layer himself in them like humans can. Therefore, he gets whatever relief he can from the weather. The second reason why your dog may be digging is from sheer boredom. Yes, dogs do get bored, especially if they cannot be with their masters (meaning you) all day. They are "man's best friend" for a reason, but if left to their own devices, they make up their own entertainment. Unfortunately, that could come in the form of digging.
What you want to do is redirect that digging behavior into alternate avenues. Sometimes, it takes being sneaky and sometimes it is all a matter of physically showing him a "safe or good" place he can dig without repercussions. There are certain breeds that are just prone to digging, so if your dog is one of those breeds, you will just have to take deep breaths and practice a little patience when dealing with the digging. Also, you can try these tips to tame that digging instinct:
1. Put a surprise in the hole your dog dug. Many dogs start on a hole; leave it for a while; and then come back later to continue the digging process. During one of those digging 'breaks,' put an unpleasant surprise in the hole. For example, some dogs don't like water. Spray some bitter apple in the water as an extra precaution. This bitter apple spray can be found in most pet stores easily.
2. Fill the holes up with natural stuff around your yard. Dogs are partial to 'clean' dirt. If you put dead leaves, rocks, mulch, sticks and other undesirable doggie stuff in the hole then cover it up with a thin layer of dirt; chances are that when your dog starts digging again and finds that stuff in his hole, he will stop. And if does not, refill the hole again, only spray the contents down with bitter apple spray. Most dogs don't like the smell and will stop digging in that hole.
3. Provide a special place for your dog where he can dig safely and reprimand-free. Dogs love to dig and it is in their nature. It may take some time to train your dog to dig only in that area, but it can be done. Choose a sandbox or and un-landscaped area of your yard where you don't mind a few holes and cordon it off for your dog. Bury some dog treats for him to find and show him that he can dig in that area. Encouragement may be necessary, especially if he has been reprimanded in the past for digging. However, once he discovers he can dig there, he will be one happy dog.
When you create a special place for your dog to dig, you have to keep the "excitement" going for him. Periodically bury a treat or toy so he always has something to find. Because dogs do get bored, after digging in the same spot for a while, he may decide somewhere in another part of your yard may look better. Also, replenish the sand or dirt in his special area periodically. Dogs love fresh dirt over the packed variety. There are also instances when your dog may prefer your flower beds over his own special digging place. Buy some animal essence (hunters use this to attract animals during hunting season) and sprinkle it in the flower bed area. This smell of another animal may deter him from digging.
All of these tips essentially retrain your dog to dig in only the proper designated places you have set for him. Just remember that they love to dig and are not being malicious when they do.