This reminds me of an abscessed tooth.

Our sheltie wound up having a hole in the side of her mouth. We thought she got it caught on a nail or something.

When we took her to the vet, we were told it was due to a far along abscessed tooth.

Vet visit ASAP!