Installing a sprinkler system in your yard that reacts when it senses an animal's motion is a safe and simple way to scare away dogs. This could also be beneficial for your grass. You can keep the sprinkler on at times when dogs seem to come around the most, or you can set it to be activated by motion to surprise and scare the animals.
Vinegar is useful for many household purposes, and you can also use it to keep dogs away from your lawn. Fill a plastic spray bottle with undiluted vinegar and spray it all around the yard and garden to keep dogs away. The scent is unattractive to the animals and will keep them from entering your yard. This will have to be done daily to keep the vinegar scent strong.
Animals don't like the way pepper smells, so sprinkle some vigorously around the yard. Use cayenne pepper and black pepper for effective results. Make the line of pepper thick and going around any area you want to keep dogs out of.
If none of the other methods work and you just can't keep dogs off your lawn and you have the money to invest, a fence may be the best option for you. The fence can be wooden, wire or chain link, and it is the only completely foolproof way to keep dogs from entering your lawn.