I tend to time the switch out of despotism, depending on if I am building a wonder or not- and the city producing the wonder. It might be worth a few turns of anarchy just to get the mining boost from a better government in a wonder-building city. But that's usually only if I've recently started the wonder race. Bad idea to switch governments in the middle of the war. And I hate conducting diplomacy during anarchy... there's nobody in power in my government to talk to!