What’s going on with a dog in pain while eating:
https://dogshealthproblems.com/dog-in-pain-when-eating/
A muscle problem:
Another problem that may affect dogs is masticatory myositis. Myositis means inflammation of the muscle. In this case the muscles are associated with chewing (mastication). Masticatory myositis is an immune system disorder that causes pain in the muscles of the head and therefore makes it painful and difficult for dogs to open their mouths and eat. Basically what happens here is that the dogs antibodies attack the muscle fibers of the muscles responsible for chewing. Masticatory myositis is usually seen in middle-aged or older dogs, and with time, dogs develop muscle atrophy along with a decreased range of motion of the jaw. Myositis is treated with prednisone and medications to reduce pain. Providing the affected dog with warm, softened food is more soothing then dry, hard food.

Masticatory Myositis in Dogs:
By Robin Downing, DVM, DAAPM, DACVSMR, CVPP
https://vcahospitals.com/know-your-pet/masticatory-myositis-in-dogs
Masticatory muscle myositis (MMM) is an immune system disorder in which the dog’s immune system identifies the dog’s own muscle tissue as foreign and attacks it. The masticatory muscles are the muscles involved with chewing. MMM causes these muscles to become swollen and painful. Dogs with MMM cannot open their mouths without excruciating pain.

Myasthenia gravis and masticatory muscle myositis in a dog:
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC340171/
Abstract: (read the full article at the link above)
A 21-month-old, castrated male Vizsla was presented for pelvic limb weakness, difficulty opening his mouth, ptyalism, voice change, and urinary incontinence. Myasthenia gravis and masticatory myositis were diagnosed. The unusual clinical findings, diagnosis, treatment, and case outcome are described, followed by a brief discussion of myasthenia gravis and masticatory myositis.