If there's a cavity on the tooth and there's pain while chewing it is quite possible that the same is because of the tooth is infected and the infection has reached the pulp and beyond ( inner core of the tooth).this could be treated with root canal treatment after confirming the same with an x ray . Painkillers could give you temporary relief till you can start the treatment.
Next Steps
online consult followed by a visit to your nearest dentist for a definitive treatment
Health Tips
seek early attention as the same could cause continued discomfort and abrupt increase in pain.