Kakashi gaiden was clearly the precursor hint he gave out. Therefore, he must have had it planned significantly before it was established in the manga. Bottom line? I think it was planned out while he was writing part 1.
We know for a fact that Kishi did not have everything written out beforehand, that would be impossible. He simply had large storylines written out and would fill in the gaps as it was needed. Clearly he didn't know page by page how it was going to come together, things like that.
Either way, I'd say that once Kishi got his sponsors and knew he'd have his shot at the series, he began to come up with storylines like this. Keep in mind that long before we were ever even told Obito's name, we saw pictures of him, Kakashi and Rin with Minato. So clearly Kishi came up with the character very early on and likely sometime between the very beginning and perhaps as late as midway through part one was when he came up with the general idea of Tobi and Obito secretly being him. Of course, things like Madara, elderly Madara and everything with the sage and Rinnegan were probably established AFTER Tobi being Obito, if you ask me.