Digging Problems
Dogs dig to bury bones, and later to dig them up again. Dogs dig after eavesdropping on private ultrasonic conversations of subterranean critters Dogs dig out of boredom, and dogs dig to escape. But by and large, most dogs dig for the sheer fun of it.

Dogs Don’t See Your Problem
Dogs consider digging to be a perfectly normal and natural doggy activity. In fact, terriers consider digging to be their very reason for being. It would therefore be fruitless to try to stop your dog from digging altogether.
Prevention and treatment of misplaced digging focus on management and education: preventing your dog from digging in inappropriate areas and redirecting your dog’s natural digging-desire to a suitable area.

Prevent Digging in Your Absence
When you are away from home, keep your dog indoors.
When you are at home you must supervise your dog in the garden at all times. Leaving a dog unsupervised can lead them to predictably learn to bark, dig, and escape, and become over-excited whenever let indoors. 

Make sure your dog is well exercised (psychologically as well as physically) and entertained, and thus has no need to dig to escape from the garden.

Teach recreational diggers to become recreational chewers. If your dog is busying himself with a chewtoy or long lasting treat, they have little time to dig.

Consequently, chewtoys stuffed with breakfast kibble are the best objects to leave indoors, or to bury in your dog’s digging pit. You must teach your dog how to entertain himself outdoors. This means your dog needs chewtoys outside, too.

I'm happy for my dog to dig in certain areas:

Redirect Digging to a Digging Pit
Since you consider your dog’s choice of digging locations to be inappropriate, choose a location to your liking and teach your dog to dig there.

Build your dog a digging pit (much like a child’s sandbox) in a suitable area of the garden. Bury a cow’s ear (or some interesting treats) in your dog’s digging pit.  Your little doggie will be utterly delighted when
they find them.

Now, this single simple procedure may not totally prevent holes in other areas of the garden, but your dog will now be much more inclined
to dig in their digging pit. After just one remarkable find, your dog will prefer to excavate in digging pit, where they once found something very worth finding. Every morning, fill several chewtoys with your dog’s breakfast kibble and bury them in the digging pit. Your dog will discover that the digging pit is a virtual treasure trove where they can find toys for sustenance and entertainment.

Once the dog’s digging activities have been redirected to a suitable location in your garden, you might consider protecting other parts of the garden. Lay down chicken wire or chain-link fencing over the lawn and flower beds, add plenty of topsoil, and reseed.

I don't want the dog digging at all:

As mentioned earlier, digging is a natural behaviour, and if you want to prevent all digging in the garden you must be prepared to keep on top of your dog's boredom.

  • Perform time-outs for digging behaviour. If you notice your dog is digging attach a trailing line and lead the dog inside the house the second they begin to dig. Do not punish the dog, touch them, give them eye contact or speak to them. See our advice on time outs. Repeat, repeat, repeat.
  • Properly exercise your dog. Once they are able to accompany you on walks you need to ensure they are getting enough exercise to burn off excess energy.
  • Play with your dog. Most rescue dogs are not playful to begin wiht, but some are. Ensure that you are playing with your dog regularly to keep them entertained.
  • Tire them out mentally. Enrichment and mental stimulation is important. Dogs like challenges and can get bored very quickly if they don't have something to work at. Most of Oakwoo's rescues enjoy a stuffed Kong. Fill it with cheese, chicken, kibble etc and freeze it, you will find that it takes your dog a good amount of time to get through it. If you dog is especially food oriented there are lots of puzzle toys on the market that you can try. Mix up their puzzle toys so they have to work hard and tire themselves out.

Adapted from The Behaviour Company: Digging Problems