Klaas4; it is actually either biting your top lip w. your bottom teeth or biting your bottom lip w. top and is called “bite your lip.” sjg is right; it is a sensory distraction. Similarly, when I was young and had cavaties filled without novocaine, I used to dig my nails into the palms of my hands.
“Bite your lip” is also an idiom that means making ” a conscious effort not to react or to keep quiet about something that displeases you.”
Boffin is correct about those idioms. “Bite the bullet” was literal; usually during some primitive surgery before ether was discovered: the wounded were given bullets, straps or sticks etc to bite down on….also used by women delivering babies in some cultures.
“Grit your teeth” is a common expression but probably means to clench your jaw..
From Wickipedia:
“Bite the Bullet may refer to: Accepting something difficult or unpleasant, or adopting an attitude that allows one to do so. The expression alludes to the battlefield medical technique of literally biting a bullet during surgical procedures as a primitive form of pain management.”