When dogs are segregated or storm is coming, they will dig the earth as unease. As well, if dogs stay in a environment that's not stimulating, he will also dig to find fun.
Solution: If your dog has a nature with digging, it would be better to find a acceptable manner for his digging rather than stop him from digging. For example, you can give him a special tub for digging, the tub may be fitted with soft sand or soil, as well, you can embed bones, toys or others into soil, which can satisfy his curiosity.
If your dog always dig in the same place in your yard, you can lay a snare for him in the place, let him dislike the place, for example, you can embed a balloon into shallow soil, the shallow will exploded if he digs it, your dog will be frighten to dig the place anymore.
Don't berate your dog, it's not useful, because you can't always find that he's digging. As well, some dogs dig for your attention, your blame will stimulate your dog to dig the earth more often.