I tend to specialize in Antiquity when the next growth event is more than 10 turns away and I have captured all resources. In Exploration I (and most of us) pretty much specialize all towns on t1 if all the resources have been captured. Same for Modern.
I also specialize the towns earlier in Exploration and Modern. As
@MutilationWave notes, the other thread has lots of considerations for *which* specializations to choose. I also found this video from Van Bradley to be helpful
It doesn't address the question of "when", but "which".
For "when", consider the difference between a Growing Town and a specialized one. The Growing Town is using its own food to grow onto additional tiles. My focus then is: which tiles, and how many, do I want to grow onto? How close are the resources? Is there an opponent settlement that could grow onto them? For towns that I found in Antiquity -- in the Homelands -- most of them have finished growing onto the interesting tiles by the end of Antiquity. It's rare that I have new resources pop up in Exploration or Modern that are not in range, are not covered by the tiles I already have.
Moreover, I've just learned more about the warehouse building bonuses, especially in later ages. If I wait to specialize a town until it has one or two food warehouse buildings, then its impact on the city/cities that town is feeding will be amplified. If I want to make this particular town a "Hub Town" for the influence yield, I might do that sooner rather than later. I might have a more urgent need for influence for war support, for example. At the start of Exploration, I try to figure out which towns will be Hubs and which will be Religious (for the extra relic slot). Both of those specialties can come pretty early.
A related consideration -- conquered settlements. After the 10-turn unrest, a large settlement that had been a city for the AI is now just a town for me. When to specialize it? Unless it has a resource nearby that the former owner didn't grow towards, I often specialize those towns within a few turns of the end of unrest. I also need to consider whether to spend the gold to make it a city again.