Instructions
Try having a friendly talk with your neighbor. It's possible they aren't aware that the dog is causing problems and that they'll remedy the situation right away. Approach them as if you're sure they don't know about it, not in an accusatory way, and you're more likely to get a better result.
Determine the times of day that the dog has a tendency to visit your yard. Plan to put the sprinkler on at those times to deter the dog. Most will want to avoid getting wet.
Try some of the commercially available repellents, but realize this will only work if the dog defecates in the same general area (like your flower beds). Typically made up of different peppers, they are available in granulated and spray forms. The granulated form lasts longer, but the spray form has the added benefit of being a deterrent both in smell and in taste.
Know what doesn't work. It is a common misconception that placing jugs of fresh water around your yard will discourage dogs because they won't defecate where there is fresh water. This has been repeatedly proven false, so don't bother trying this method. Yelling at the dog when you catch them in the act will only teach them to look for you before they come into your yard.
Report the neighbor to the community association if there is a rule about cleaning up after your dog. Use this as a last resort, because it won't help to improve neighborly relations.
Remember that it isn't fair to blame the dog, as it is only doing what comes naturally to them. The behavior needs to either be controlled by the dog's owner, or discouraged by you. Doing something to harm the dog won't do anything to improve your relationship with your neighbor, and it's cruel to the dog.
How to Stop Dogs Fouling a Yard
Few things can cause more discord between neighbors than when one allows their dog to use another's yard as its own personal bathroom. Although you may feel justified to do differently, discouraging your neighbor's dog from doing this should be done kindly and diplomatically whenever possible.