Sometimes it maybe due to neuralgic pain (trigeminal neuralgia). In this type of pain, it arises when you touch any trigger point like shaving, brushing, sometimes swallowing etc. and it appears for some minutes.
Next Steps
Pls consult oral and maxillofacial surgeon or Neuro physician with detailed history.