Given a stochastic differential equation
$$ dX_t = f(t,X_t) dt + \sigma(t,X_t)dB_t$$
where $B$ represents standard Brownian motion, if I wanted an ODE for the mean of the SDE, I could write for any $T > 0$
$$ X_T = X_0 + \int_{0}^{T}f(t,X_t)dt + \int_{0}^{T}\sigma(t,X_t)dB_t $$
then by taking expectation on both sides and since the integral with respect to $B$ is a martingale and has mean zero, one has
$$ \mathbb{E}(X_T) = \mathbb{E}(X_0) + \mathbb{E}\left(\int_{0}^{T}f(t,X_t)dt\right). $$
My question is, when can one exchange the expectation and integral with respect to $t$ to obtain $$ \frac{d}{dt}\mathbb{E}(X_t) = \mathbb{E}(f(t,X_t)) $$