General conversation we use time but professionally we don't.
Headcodes originated as lamp codes which were displayed using 4 (?) brackets on the front (head) of a steam locomotive. Different lamps on different brackets identified the type of service, eg express, freight, freight stopping in section and so so signalers could signal appropriately.
The route codes appeared later and I think were mostly used by the Southern and GWR. Southern tended to display route codes and the GWR and BR Western region would display the train reporting number but the lamp codes remained. Headcodes eventually spread over the network but the 4 figure headcode we know and love today came after steam with most early diesels and electrics built with a headcode box. All this was still mostly for signalers.
As signalling moved from men in boxes to signalling centres and trains were represented as their headcode on a panel or screen the trains themselves generally stopped displaying them but every single train still runs with one. And it still does exactly the same job as it did 100 years ago, identifies the exact details of the train;
1 - Express passenger
P - London - Norwich service
27 - Unique train ID