Through X-rays and a visual inspection by the dentist. Often cavities may cause unpleasant symptoms such as:
Toothaches
Sensitivity
Discoloration or dark spots
Bite discomfort
Holes or crevasses in your teeth