Functional brain networks exhibit modular community structure with highly inter-connected nodes within a same module, but sparsely connected between different modules. Recent neuroimaging studies also suggest dynamic changes in brain connectivity over time. We propose a dynamic stochastic block model (SBM) to characterize changes in community structure of the brain networks inferred from neuroimaging data. We develop a Markov-switching SBM (MS-SBM) which is a non-stationary extension combining time-varying SBMs with a Markov process to allow for state-driven evolution of the network community structure. The time-varying connectivity parameters within and between communities are estimated from dynamic networks based on sliding-window approach, assuming a constant community membership of nodes recovered by using spectral clustering. We then partition the time-evolving community structure into recurring, piecewise constant regimes or states using a hidden Markov model. Simulation shows that the proposed MS-SBM gives accurate tracking of dynamic community regimes. Application to a task-evoked fMRI data reveals dynamic reconfiguration of the brain network modular structure in language processing between alternating blocks of story and math tasks.