It may differ from victim to victim, but a significant amount of planning for at least two victims may be assumed. Victor, the third victim (Sloth), was tied to his bed for exactly a year; keeping a person alive and hidden for that amount of time implies an enormous amount of preparation as well as dedication. This suggests that John Doe already selected Victor and began planning his entire work well before he captured him. Doe probably also had his eye on Eli Gould, the second victim (Greed), because he was the one who kept Victor out of jail. These are the only two victims with a clear connection to each other, as the other 3 victims do not appear to be connected. It is possible that Victor and Eli Gould were among the first victims targeted, even though they were not the first two to be found. Indeed, in John's home, several newspaper clippings can be seen on a cupboard that describe Eli Gould defending Victor and getting him an acquittal, so this may have been how John Doe selected them.
Which brings us to the seventh victim. It is reasonable to assume that Mills was selected 'on the spot'. He was recently transfered to homicide, and John Doe could not have known beforehand that Mills would be one of the detectives working on the case. Doe meets up with Mills at the scene of the Sloth murder, and personally experiences Mills' violent temper which would make him the ideal candidate; later, Doe has the opportunity to kill Mills in the alley, but doesn't, probably to preserve him for becoming the seventh victim. It is unknown if Doe had originally intended another person as the Wrath victim before he met Mills, and decided Mills would be the perfect candidate (he can be heard mentioning over the phone that he will be readjusting his schedule); but it makes sense that he intended the seventh victim to be an officer anyway: an officer of the law driven to the point of killing an unarmed suspect would attract a lot of (media) attention, and would ensure that his work would be discussed for years to come.
It is more difficult to determine when the other victims were selected. There is a picture of the fourth victim (Lust) in John's house, which may imply he had his eye on her some time, but without an indication of when it was taken, there is no sure way to tell. When John says that he has to readjust his schedule, it may just mean that he is changing the location of the murders, or his 'headquarters', not the victims per se. He had a special murder weapon created for the Lust victim, and the man he forced to use it on the victim seemed to be a completely random guy, but this does not exclude the possibility that the victim was carefully selected long before that. The same goes for the first (Gluttony) and fifth victim (Pride): they could have been selected shortly before, but given John's meticulous preparations, it is not unthinkable that he had them targeted for some time. Also, John mentions about the Pride victim that she was 'so ugly on the inside [that] she couldn't bear to go on living if she couldn't be beautiful on the outside', implying that he knew her personally, and she wasn't selected shortly before.