Our proposed work analyzes and models the photonic crystal (PhC)-based elliptical ring resonator for detecting viral and bacterial infections. Optical sensors show extreme results as sensing devices. So, they are broadly accepted in the medical field for the rapid and effective diagnosis of diseases. Optical biosensors are designed to detect cancer, malaria, typhoid, tuberculosis, etc. The principle behind the working of optical biosensors is a shift in the peak resonance wavelength corresponding to the small changes in the refractive index values. Due to the rapid mutation and replication of viral pathogens in the human cell nucleus, there is high demand for sensors that provide accurate results for viral and bacterial diseases in seconds. Hence, optical biosensors can give results in a short amount of time with a high sensitivity. The proposed sensor achieved a high sensitivity of 881.25 nm∕RIU for tuberculosis and 555.55 nm∕RIU for hepatitis B. The quality factor and figure of merit is also calculated, and their values come out to be 624.37 and 346.38, respectively, in the case of typhoid and Bacillus cereus. The platform used for simulating the analytes is the finite-difference time-domain.