This is a form of liaison: a consonant is inserted to breaks up hiatus, a sequence of vowels.1
Specifically, this is a liaison obligatoire, because the verb and subject pronoun form a tight bond.
Hence, you insert ⟨t⟩ if the verb ends with a vowel and the pronoun begins with one.
As far as the spelling goes, this situation only arises with the pronouns il, elle, and on.
A-t-on déjà payé ?
Fera-t-il la tâche avant jeudi ?
Note that in this inversion, a final e muet is considered non-silent,2 so you insert ⟨t⟩.
Regarde-t-elle la télé ?
In terms of writing, that's all you need to know. However, listening to the actual sounds, notice that the last sound you hear in many verbs is a vowel. So you don't write an extra ⟨t⟩, but you do pronounce the last consonant, usually /t/.
Veut-il toutes les pâtes ?
That also affects ils and elles: they start with a vowel and the verbs end with a vowel sound, despite being spelled ⟨nt⟩. That's true even in present tense, because of the e muet phenomenon above.
Vendent-ils du café ?
Voudraient-elles déjeuner chez toi ?
1 Meanwhile, four pronouns begin with consonants: je, tu, nous, vous. The last two have conjugations that end in vowels: -ons, -ez. But je and tu have conjugations that end in consonants. This results in the opposite problem: overfull consonant clusters. That question is discussed in this thread.
2 In practice, that doesn't mean you'll actually hear a clear re-gar-deu-tel. A deletion rule can still follow.