You can refuse it, I tested positive for strep b and they said my baby would have it put on because of that, however none of them had it after my first and have all been c sections.
It's an antibiotic just in case. I don't know the legality of it for doctors, but as a parent I think you can refuse it.
I believe it is required by law because if a woman has certain conditions it can cause blindness in the baby (I think it is an STD). You can argue that if you don't have the STD, your baby does not need the ointment, but I do think it's a legal thing not a doctor's choice. Someone might correct me if I'm wrong.