I had several teachers in high school and college who would do things like homework could give you about a 10% boost in your grade (eg, from a C to a B), or you could just take your test scores. One class I vividly remember after every quiz/test the teacher would say something like "OK people, I'd like to tell you that you need to do your homework, so you can do well on the quizes, but [toast0] got the best score in the class, and didn't turn in any homework, so I can't; the rest of you, should do your homework though." That was high school chem; I did read the assigned texts, but I didn't bother to do most of the homework, because it was very repetitive, and I was doing just fine as-is; I can't remember if I would turn in the couple of problems I did do, or not even bother to write them down.
Sometimes quizzes/exams would have extra credit questions, so you could score something like 120/100 on them. Other classes had a bonus if you got a 5 on associated AP tests.
I've definitely had classes where the homework was optional. In my case it has been higher-level math courses, where there are regular quizzes to verify that you know the material.