To treat pain from a cavity:
Take over-the-counter pain relievers.
Rinse with warm saltwater.
Apply a cold compress.
Avoid triggering foods and drinks.
Maintain good oral hygiene.
Schedule a dental appointment for professional treatment.