At the highest point, the kinetic energy is $E_{top} = E \cos^2\theta$. By conservation of energy, the potential energy at the highest point is the initial total energy minus the kinetic energy at that point: $PE = E_{total} - E_{top} = E - E \cos^2\theta = E(1 - \cos^2\theta) = E \sin^2\theta$.