What did the teacher do when she saw you in a pub?
This sentence is in Past Indefinite. Past Indefinite is used for a past action and Past Indefinite is formed with the help of the suffix – ed for regular verbs. We use the second form of the irregular verbs. The auxiliary verb of Past Indefinite is to do (did). We use the auxiliary verb when we form negative and interrogative.
Negative — did + not + verb.
Interrogative — Did + subject + verb.