Inflation has risen by more than expected due to an increase in energy bills, official figures showed.