wenn first: verb, comma, verb
Start with the wenn-clause and the whole clause takes position 1 — so the main verb comes immediately after the comma: Wenn ich Zeit habe, besuche ich dich. Two verbs meet at the comma: habe, besuche.

Tip
Basic pattern: Wenn ich Zeit habe, besuche ich dich. The verb follows the comma. You can also add dann: Wenn ich Zeit habe, dann besuche ich dich. In both patterns, the subject ich follows besuche.