Huh
I wonder if part of Paps' mouth went into the hole, and that made a kind of "phantom hand" illusion amputees have
Basically, if you are missing a hand or something and something almost hits the stump, but not quite, you might feel the pain, as if your hand was still there.
What I'm saying is Gaster's brain/soul/whatever thinks that the hole in his palm is still there, and theoretically, when something goes through it (Like Papyrus's mouth and/or the towel he had covering his hand, which would further the illusion that the hole is filled) then he feels a certain amount of pain, depending on the severity of the injury
Oh wow i got really scientific there