Your description suggests a deep cavity as it is associated with pain.
If the pain is in any other teeth- it could be due to trauma or hard brushing which will subside in 2-3 days automatically.
If the pain and swelling is in the very last teeths ( wisdom tooth ) - the third molar might be errupting. If it fails to errupt extraction is the option.
If the pain is associated with a tooth that has cavity- the cavity is deep and might go for root canal treatment.
However proper diagnosis can be made once you visit a dentist
X-ray might be recommended for the same
Next Steps
visit a nearby dentist asap
Health Tips
for temporary pain relief use cold packs like ice cubes or drink cold water.
Luke warm salt water gaurgle will help.
donot delay the treatment