You have to know the energy eigenstates. Suppose you know that $\Phi (x)$ is an energy eigenstate with $E = E_0$. Then the probability that your state $\psi(x)$ will be measured to have energy $E_0$ is:
$$ P(E_0) = \int_{-\infty}^{\infty} \mathrm{d} x \ \Phi^*(x) \psi(x) $$
You can do this for the full set of eigenstates $\Phi_i$ to get the wavefunction in an energy basis (instead of the position basis you have it represented in now). Note you can't always do this for an arbitrary $E$, because only a subset of them (the eigenvalues) are going to be energy eigenstates, although for some systems (scattering states) you have a continuous basis for energy.
EDIT: Another thing I forgot to add is that your energy states may be degenerate--there might be multiply $\Phi$ that could give you $E_0$. In that case you need to add up the different probabilities from each one.