Today’s Treasury dates from around the Norman Conquest. Even before 1066, the Anglo-Saxon Treasury collected taxes (including the danegeld, first levied as a tribute to the Vikings to persuade them - sometimes unsuccessfully - to stay away) and controlled expenditure.
The first “Treasurer” was probably “Henry the Treasurer”, who owned land around Winchester; the site of most royal treasure of both the Anglo-Saxons and the Normans. Henry is referred to in the Domesday Book (a systematic tax assessment of the whole country undertaken by the Treasury) and is believed to have served William the Conqueror as his Treasurer.
For most of the mediaeval period the office of the Treasurer was within the Exchequer, which managed and accounted for the royal revenue, as well as collecting and issuing money. The Exchequer wasn’t always effective at its job: in 1433, for example, war with France led to a deficit of £30,000, the equivalent of over £100 billion today.