A crystal oscillator is used to generate precise and stable frequencies in electronic circuits. It utilizes the mechanical resonance of a vibrating crystal, typically made of quartz, to provide high accuracy timing signals for various applications such as in clocks, microprocessors, communication systems, and other electronic devices.