I was a categorical surgery resident/intern at a pretty good program in Philadelphia. I too had been considering ophthalmology as a MSIV, but ended up going into GS. It became clear to me pretty quickly that I had made a mistake--general surgery just didn't match my temperament, etc. Once I got the guts to actually make "the decision," I spoke with my program director. He was really nice, and even introduced me to the Wills program director who served as my mentor during the whole process of applying to ophthalmology. My fellow residents were super nice and I was able to switch calls etc. in order to attend interviews. My advice, though, is to pay attention to timing. I was very late in entering the ophthalmology match. When you do decide to go for it, make sure you are able to get your letters and application in early. I did have a year between finishing my surgery internship and starting ophthalmology, so I did a year of research in plastic surgery and transplantation. And I read. Overall I have no regrets. I love ophthalmology and feel that the sacrifices and time lost involved in the switch are more than compensated for by a much better fit for me and also a much brighter future as an attending (it goes without saying that it's a much nicer life as an attending ophthalmologist than an attending general surgeon in terms of hours, headaches, etc).
So to summarize:
Notify your program director (only) once you've really committed to making this switch.
Find an ophthalmologist (preferrably an academic) to serve as your mentor during the process.
If you match directly into an immediate vacancy, that's great. If not, you'll have to come up with something to do during the interim year. Make it productive and enjoyable. It's a great time to beef up your CV and to read a lot of ophthalmology.
If this is really what you want to do, I say go for it. But a person doing this should have a relatively strong application (USMLE, grades, letters of rec, etc.) because you will be reviewed as an "atypical" applicant. And if you lose your general surgery position and don't match into ophthalmology, you will definitely be up the proverbial creek for a while.
Good luck.