1: She said she would do it when she came home.
2: She said she would do it when she comes home.
Which is correct, and why?
Her actual words were ‘I’ll do it when I come home’, and she meant that she’d fulfil some obligation or other on her return. When someone else says what she said, it becomes, in a rather formal style, ‘She said she would do it when she came home.’
‘She said she’d do it when she comes home’ says the same thing in a rather less formal way. Even less formal is ‘She said she’ll do it when she comes home.’
Yes, both are considered correct, it really just depends on what you want to say.
In (1) the action is presumed to be 100 % complete, and it is in the past. However, the sentence is a bit ambiguous and leaves the possibility open to the idea that the action may still not be done.
In (2) the statement was made in the past, but it refers to a future event by using the present tense. The present tense is pretty useful, because it can also refer to future events, like in your example.