If your mouth opening has been reduced temporarily because of the cavities, then a course of antibiotics and pain killers should do the magic. If it has been like that forever or for a long time now, you have to get it assessed.
Next Steps
Look for an Oral and Maxillofacial Surgeon in your area and get your mouth opening issue sorted. Rest of the treatment can go hand in hand.