I believe the year was 1809, and all Jews had to take fixed, inheritable surnames (of Yiddish or Russian origin and of their own choosing), so they could be tracked for taxation and other purposes.
[Addendum: After looking around, it seems it is more complicated than I remembered (history always is). Different parts of the Russian Empire had different decrees (ukases) passed. The Austrian, Napoleonic, and Prussian Empires also got into the act. See the article in the first edition of the Encyclopedia Judaica and this genealogical site have some more information. Some names could be chosen, but from a fixed list, and others had arbitrary names forcibly given to them.]
Was that just for Jewish people - and didn’t they have inheritable surnames before that time? It seems very late and leads me to wonder when various groups of people/nationalities began to use surnames and when they became a legal necessity. there’s got to be a website about all this somewhere.
(It also makes me wonder if Sikh families in Britain have to use their family name for legal purposes, cause most of the Sikh families I know use ‘Singh’ as their surname and I didn’t realise it wasn’t a family name until one man, having fallen out with the Sikh community, insisted that his kids were know by their family name (’Digwa’) instead of ‘Singh’ from then on - he also shaved his beard and had his sons’ hair cut)