Most studies on adaptive networks concentrate on the properties of steady state, but neglect transient dynamics. In this study, we pay attention to the emergence of community structure in the transient process and the effects of community-based control strategies on epidemic spreading. First, by normalizing the modularity, we investigate the evolution of community structure during the transient process, and find that a strong community structure is induced by the rewiring mechanism in the early stage of epidemic dynamics, which, remarkably, delays the outbreak of disease. We then study the effects of control strategies started at different stages on the prevalence. Both immunization and quarantine strategies indicate that it is not ‘the earlier, the better’ for the implementation of control measures. And the optimal control effect is obtained if control measures can be efficiently implemented in the period of a strong community structure. For the immunization strategy, immunizing the susceptible nodes on susceptible–infected links and immunizing susceptible nodes randomly have similar control effects. However, for the quarantine strategy, quarantining the infected nodes on susceptible–infected links can yield a far better result than quarantining infected nodes randomly. More significantly, the community-based quarantine strategy performs better than the community-based immunization strategy. This study may shed new light on the forecast and the prevention of epidemics among humans.