The original sentence should be “the specialty of an ophthalmologist is ophthalmology” but it’s an odd sentence.
In medicine, a “speciality” is something that requires additional training and focuses on specific ailments or skills. In addition, there can be sub-specialities. So an ophthalmologist is a specialist who does eye surgery, but to do retinal surgery an ophthalmologist would need sub-specialty training.
“specialty” is used often in medicine, but it can also be used more generally.
His specialty is taking free-kicks.
Her speciality is teaching piano to students who want to be professional musicians.
His specialty is finding investors.