The word when can take finite clauses as a Complement (clauses with a tensed verb). When we have a finite clause, the Subject of that clause must be present:
- *He did this because was angry. (ungrammatical)
- He did this because he was unhappy.
- *She laughed, although was sad. (ungrammatical)
- She laughed although she was sad.
This is not true about non-finite clauses, which do not have any tense:
- Bob was sacked from his job, due to always being late.
In the sentence above the non-finite verb being does not need a Subject. It has no tense, it is a participle, not a tensed verb. We understand the Subject of being to be the same as the Subject of the verb in the main clause, Bob.
The Original Poster's example
The conjunctive preposition when can take clauses with tensed verbs. When these clauses have tensed verbs (past or present tense), they must have their own Subject.
Although the Subject of hurt is the same as the Subject of was wrestling, we need to use a full Subject for the second clause:
He was wrestling when he hurt his ankle.
He was wrestling when hurt his ankle. (ungrammatical)