Time evolution of states - Is total energy constant or not? Suppose the state of the particle is given as follows:
$$ |\psi_{(t)}\rangle = \frac{1}{\sqrt2} \left( e^{-\frac{i\omega t}{2}} |0\rangle + e^{-\frac{3i\omega t}{2}} |1\rangle \right) $$
Where the wavefunctions are: $\phi_0 = \left( \frac{1}{a^2\pi} \right)^{\frac{1}{4}} e^{-\frac{x^2}{2a^2}} $ and $\phi_1 =  \left( \frac{4}{a^6\pi} \right)^{\frac{1}{4}} x \space e^{-\frac{x^2}{2a^2}} $.
I have found the expected position and momentum with time:
$$\langle \psi_{(t)}|x|\psi_{(t)}\rangle  =  \frac{a}{\sqrt 2} \cos (\omega t)$$
$$\langle \psi_{(t)}|\hat p |\psi_{(t)}\rangle = \frac{i\hbar}{a \sqrt 2} \cos (\omega t) $$
Then I try to compute the rate of change of energy:
$$ \frac{d}{dt} \left[ \langle \psi_{(t)}|\hat p |\psi_{(t)}\rangle + m\omega^2 \langle \psi_{(t)}|x|\psi_{(t)}\rangle \right] =  - \left( \frac{i\hbar}{a\sqrt 2} + \frac{a}{\sqrt 2} m\omega^3 \right) \sin (\omega t) $$
This means that the total energy fluctuates with time, which is strange as shouldn't the total energy be conserved?
 A: It looks like you're working with the one-dimensional simple harmonic oscillator in which case your expression in brackets for which you have computed the time derivative is not the expectation value of the Hamiltonian.  Your $\hat p$ should be squared and divided by $2m$ and $\hat x$ should be squared.
Also, you ask

shouldn't the total energy be conserved?

In this case, the expectation value of the Hamiltonian should be conserved because it has no explicit time dependence.  To be more explicit, recall that in general, the time derivative of the expectation value of any observable $\hat O$ satisifies
\begin{align}
  \frac{d}{dt}\langle \psi(t)|\hat O|\psi(t)\rangle = \frac{i}{\hbar}\langle\psi(t)|[\hat H,\hat O]|\psi(t)\rangle + \langle\psi(t)| \frac{\partial \hat O}{\partial t}|\psi(t)\rangle.
\end{align}
As a special case, the time derivative of the expectation value of the Hamiltonian satisfies
\begin{align}
  \frac{d}{dt}\langle \psi(t)|\hat H|\psi(t)\rangle = \langle\psi(t)| \frac{\partial \hat H}{\partial t}|\psi(t)\rangle
\end{align}
since $[\hat H, \hat H] = 0$.  Therefore any time $\partial \hat H/\partial t = 0$, the expectation value of the Hamiltonian is conserved.
