There has been a surprise contraction in retail sales in December, despite the month being key for many retailers due to Christmas shopping, official figures show.