Identify the animal that is invading the garden. Often the culprit isn't a dog at all, and may be a number of other stealthy critters. Although defense against dogs may be quite effective at keeping other animals at bay, it's best to understand the fauna surrounding the garden.
Purchase a motion-activated light, sound or sprinkler system. This system is quite easy to install and is almost always an effective deterrent to small animals, including dogs. The light, sound or sprinkler is activated when the animal crosses the sensor's path and drives away the pest.
Install a fencing system around your property or yard. Dogs love to dig, so use a deep-seated fencing solution. Height is also a consideration. If dogs are determined to get at a garden, it is not unheard of for them to actually climb a small fence.
Spray or spread commercial dog repellent around the perimeter of the garden and yard. These repellents can be found at most garden retailers, such as Lowe's or Home Depot. Look for a product that can deter other small animals, as well as dogs.