Want to avoid this? Create a legitimate digging spot in your backyard and teach your dog to dig only there. Decide whether you want to create a particular spot in the yard or use an old sandbox or other container which you can put dirt into.
Bury some delicacies (frozen Kong, favourite chews or toy) You can fill old paper towel holders with treats, seal the ends up and bury that too. Be creative!

The first couple of times you can have your dog watch you bury something so he knows where to sniff. Then, you can have your dog wait inside while you hide yummy stuff. Guide him to the digging spot and let his nose do the work! 

Most important is to prevent your dog from digging elsewhere while he is learning to use the designated digging spot. That means during training, until he knows where to go, you cannot have the dog in the backyard unsupervised. It will be necessary to be outside with him and to redirect when necessary.
It will be worth your while if you prefer your flower beds to remain intact.