Doctor Strange finished filming in April, but according to the Hollywood Reporter, Marvel Studios hired Harmon to provide additional material for additional scenes. The film's original script was written by director Scott Derrickson (who has mostly worked on horror movies until now) and C. Robert Cargill, his co-writer on the Sinister franchise.
Last-minute rewrites can often be an ominous sign, although it's worth remembering that Marvel Studios habitually plans ahead for reshoots on all of its films, bringing back the cast and crew for a few days after principal photography has wrapped. Joss Whedon swooped in for some similar rewrites on Thor: The Dark World.
In the case of Doctor Strange, the most likely explanation is that Marvel wants the film to be funnier. Early trailers suggested a serious tone, which is relatively rare among the studio's slate of comedy-infused action franchises like Iron Man, Guardians of the Galaxy, and Thor. Dan Harmon is known for writing genre-savvy comedy, so he's an ideal choice to inject some humor into an overly serious comic book movie.