Digging Up Bones - Some dogs, especially those with a high prey drive, will dig a hole to bury a bone. It's a vestigial wolf behavior. This is a useful behavior for wolves to bury a large kill to eat later. It is not useful in domestic dogs who do not need to hoard food to survive.
Solution: This one is easy. Don't let your dog have bones, toys, or other treats that he likes to bury when he is outside. Make those available inside only.
Digging Up Critters - Moles and other animals that live under the ground can prove irresistable to many dogs.
Solution: Interrupt when you see your dog digging for a critter, and bring them inside for a bit.
To get to the other side - If your dog is only digging at the fence line, the digging is a means to an end. He wants to get out of the fence. There may be dogs in the neighbor's yard who he wants to play with (or fight with), cats running loose who he wants to chase, or he is just in the mood for an adventure. Unneutered male dogs will escape to try and reach a nearby female in heat.
Solution: Neuter your pets to reduce their desire to roam. Consider this a clear communication from your dog that what is on the other side of the fence is more interesting that what is inside, and make an effort to change that. He may be bored and/or lonely. Spend more time with him, and give him the attention he craves. Make sure he gets plenty of exercise, as well. You can also run a chicken wire skirt around the base of the fence as extra insurance.
Real-world example: Pooh Bear, pictured here, was turned over to CARE because he kept digging out of his fenced-in yard. He was an only dog who spent most of his time alone in the yard. The neighbors had dogs, so he kept going over to visit. This led to complaints to Animal Control which led to Pooh Bear being relinquished to CARE. Pooh Bear moved into a foster home with two other dogs. Problem solved, no training involved. All he needed was company. Pooh Bear never even attempted to dig out of the fence at his foster home. He has since been adopted by a family who gives him plenty of attention and affection.
It's like the cool underside of a pillow - On a hot day, lying in a hole is a great way to cool off.
Solution: Provide plenty of shade and shelter on a hot day. Plastic kiddie pools are great for dogs to cool off in the summer. Bring your dog inside when the temperature outside is extreme.
There's nothing else to do - A bored dog will find ways to entertain himself. Digging is fun!
Solution: Play with your dog. They are a lot of fun. Make sure he gets plenty of exercise and plenty of attention. Give him lots of acceptable toys to play with so that he doesn't have to use his imagination to come up with something to do.
It's genetic - Some breeds are hardwired for digging. If you have a Dachshund, expect to find holes in your yard. They were bred to go into holes after badgers. For these dogs, digging is in their blood. There isn't much you can do to stop them from digging.
Solution: Establish an acceptable digging area where he is allowed to dig as much as he wants. Use some kind of border, such as stones or pavers to section off an area. Then, supervise your dog every time he is in the yard until he understands where he can and can't dig. Interrupt digging in unapproved areas, and reward digging in the approved area. Soon, he will learn that as long as he digs in the right place, he can dig all he wants!