Optical sensors work by detecting light intensity, wavelength, or changes in light properties due to interaction with various substances. They utilize components like photodiodes, LEDs, and optical fibers to capture and transmit light. Advanced sensors can even analyze specific biomarkers in biological samples, making them invaluable in disease diagnostics.