Ernie, before his unfortunate demise due to being hit in the eye by a stale pork pie thrown by his love rival Ted the baker, was noted for the speed of his milk cart. He and his horse Trigger “galloped into market street” which sounds rather dangerous, especially if it was contemporary, for at the time he reached Christmas Number One in 1971, a horse and cart would be competing with pedestrians and motor vehicles. Nowadays there is a code of practice for horse drawn vehicles, you can find the library catalogue record for it here or it can be read online here. It is not compulsory, but it contains a driving assessment and carriage safety checklist which can be taken into account should the driver apply to the local authority for a licence to carry passengers.
However, so far as we are aware, Ernie only carried groceries: the lyrics refer to milk of various types and a strawberry-flavoured yogurt. It also seems unlikely that he was operating in 1971 as electric milk floats have been in existence since the 1930s and would have been ubiquitous well before the 1970s. The Transport Museum, Wythall believes it has the finest collection of restored battery electric vehicles in the world and provides some examples you can look at here (click on the magnifying glasses for photographs). Keith Roberts was an employee of Morrison-Electricar and his book on the history of electric vehicles is available at the British Library here, or you can read an overview here.
If we assume that Ernie and Trigger were delivering the milk before electric milk floats, we should look prior to 1930. If you’d like to know more about Ernie’s working life in general, you can read about the sale of milk in a history book called “Retail Trading in Britain 1850-1950” by James B Jefferys. The SOLO library catalogue record can be found here and it is archived online here. For the rules on carthorses galloping in the streets of British towns we turn to the Highway Act 1835. You can read that online here. Believe it or not, a tiny part (section 72, preventing riding on footpaths), is still in force. There are various offences that are punishable by fines, but none appear to be speeding. Provided Ernie and Trigger were in control, not causing damage or obstruction, it would appear they could be as fast as they liked.
In contrast, the Locomotive Act 1865 (the Red Flag Act), which you can read about here, was created so as to ensure that steam vehicles didn’t frighten the horses. Any self-propelled vehicle had to have a man walk at least 60 yards in front holding a red flag and was limited to 4 miles per hour in the countryside and 2 miles per hour in the towns. That would surely be no match for Trigger!