Suppose $X_t$ solves an SDE.
Is it true to say that the identity,
$$ \mathbb{E}\left[e^{X_t}\right] = e^{\mathbb{E}[X_t]+\frac{1}{2}\text{Var}[X_t]} $$
holds only when the drift and volatility of $X_t$ are deterministic?
i.e.
$$ dX_t = \mu_t\, dt +\sigma_t\, dW_t $$
I ask because suppose instead,
$$ dX_t = \mu(t,X_t) \, dt + \sigma(t,X_t)\, dW_t $$
Then applying Ito, and taking expectations,
$$ \begin{align*} \mathbb{E}\left[e^{X_t}\right] &= e^{X_0}+\int_0^t \mathbb{E}\left[e^{X_s}\left(\mu(s,X_s)+\frac{1}{2}\sigma^2(s,X_s)\right)\right]\, ds \end{align*} $$
which cannot be converted into an ODE to solve for the left hand side, since the drift and volatility do not leave the expectation. Thanks!
You are right; if $(X_t)_{t \geq 0}$ is an solution to an SDE of the form
$$dX_t= \mu(t, X_t) \, dt+ \sigma(t,X_t) \, dW_t$$
then the identity does in general not hold. In fact, the solution of such an SDE has not even necessarily exponential moments. To see this, consider the process $X_t := e^{W_t}$ which is a solution to the SDE
$$dX_t = X_t \, dW_ t+ \frac{1}{2} X_t \, dt.$$
The reason why the identity holds for deterministic coefficients is basically that solutions of such SDEs are again Gaussian processes.