They could be lacking certain minerals in their diet, and dig holes in the hope of finding them in the soil in your yard.
Terrier breeds are natural hunting dogs, and will instinctively dig in the ground for prey or food.
Female dogs may dig holes as part of their natural mating behavior.