Obviously, publishing in Ophthalmology would be ideal. I can't speak on behalf of an admissions committee, but I believe that having Ophthalmology-related research experience would be prefered over publishing in a non-related field. There are many benefits beyond just having your name on a paper:
1) Your experience doing ophtho research will help you decide early if this is the career for you. Ophthalmology is a difficult field for medical students to grasp, because most schools only devote about a day's worth of lectures to ophtho during the basic science years so you learn extremely little regarding what the field is really about. If a school offers a mandatory rotation, it's usually 1-2 weeks during 3rd year, and most students are fumbling around with the slit lamp, lenses, ophthalmoscope and other gadgets and can't appreciate the meaning of what they see (or cannot see). If a student does decide to do a elective, it's usually not until late in the 3rd year or early 4th year, which is really cutting it close in terms of deciding to pursue the field, since the early match application is due August/early September. Having early exposure to the field is invaluable.
2) One of the big breakthroughs I had as a medical student in solidifying my choice for ophtho was finally being able to see something through the indirect ophthalmoscope, and putting it together with what I had been researching related to the retina. All of a sudden everything made sense, and I had a greater appreciation for everything I saw, including FAs, OCTs, etc. Having your own little island of expertise makes learning about ophthalmology, which is so different from most of what you learn in med school, that much more meaningful.
3) Once you are in the loop of ophtho research, you'll start to hear of other faculty who have some projects cooking, or overworked residents who don't have the time to write up their work. Stay attuned to these opportunities, because they can be a great way to get your name on some papers. People are more likely to give you these opportunities if you are visible, and have proven that you can work hard. It's a matter of being at the right place at the right time.
4) Programs will ask you about your research on interviews. It is a huge plus if you can speak thoughtfully about your research topic. Interviewers may not be as engaged if you're talking about research not related to the field. (In fact, not one interviewer asked me about any research I conducted that was not related to the eye). Also, interviewers want to see that you had more than just a peripheral role in a project that you may have taken on just to get some ophtho research under your belt.
5) If you work hard and closely with your research mentor, that can materialize into a solid letter of recommendation, which is key in the application process.
If you had no idea what specialty you'd want to go into, I'd recommend taking the diabetic neuropathy project since it will help your application no matter what you are applying for. But since you are seriously considering Ophthalmology, I'd say go for the ophtho research and hustle to try and get to know people and get your work published. They pay-off will be greater.