One of my Pekin ducks got an infection in his eye. This is a very common ailment with ducks in colder months because of the lack of water to bathe properly. Typically, it is easy to manage with some TLC. We purchased some saline solution and I would go outside 3x a day and squirt it in his eyes. I would never rub them or touch them, you wouldn't want to irritate it further.
Foamy eyes can often be signs of a upper respiratory infection if accompanied by any combination of sneezing, wheezing, runny nose, diarrhea or lethargy. If any of these symptoms are present further treatment and a vet visit may be necessary. This guy didn't have any other symptoms aside from the foamy eye and it was within a day or two that I could see significant improvement in his eye after the saline treatment.
Once this infection occurred I would often (once a week or so) bring out warm buckets of water for the ducks to simply dunk their heads in and give themselves a quick rinse.
Here are 2 links with some of the common duck ailments/issues: