Most of the surnames in India are caste names. Agnihotri is a caste name. Mukerjee, Banerjee, Bhargava, Sivastava all these are caste names. Many Tamil Brahmins gave up their caste surnames at the time of freedom movement. Tamil Brahmins took a lead in this. It was done on a large scale in Bihar also. Like Rajendra Prasad our first president did not have a surname.
Many Tamil Brahmins staying in the North have been forced in the recent past to have a surname. Many have taken on Iyer and Sharma. But others have taken on gotra names like Atreya, Srivatsa etc. Otherwise the father's name becomes a Surname. Like Viswanathan Anand. Actually his name is Anand. His father's name is Viswanathan. He is V.Anand. Since he was harassed for a surname he is Viswanthan Anand. Funny world.
Sir i don't think Mukherjee, Bhattacharya, Banerjee, Bhargava, etc are "caste" names which wud signify ancient occupations.
Mukherjee = Mukhya + Achar-ji
Bhattacharya = Bhatta + Acharya
Achari and Acharya was the title used by those who were qualified in Sthapatya Shastra (temple building, temple architecture, etc). They were artisan groups. The Acharyas of the Vishwakarma "caste" were wide spread because of temple-building activity in numerous places.
An example of south india:
In the Pallava kingdom, in the tax-department (Puravuvari-tinaikkalam), the possible grade of officers were (from highest to lowest) were - Kankani (examiner of accounts), Nayagam (superintendent of accounts), Mugavetti (index keeper), Varippottagam (tax-registerer), Pattolai (registar filing orders of the king). [pallava possibly just means a palli-van, phal-van, or some such thing meaning one who resides in a palli settlement, no varna here. In proto-nostratic which is pre-dravidian, and pre-indoeuropean,
pal (phal) means a 'settlement"].
Even today we need a "patta" document to register a land. These terms are old. The names have survived. One cannot expect people to be professing the same "caste" (occupation) upon the defeat of their kingdom. Neither can we expect them to be professing the same "caste names" in such cases.
Apparently india was made up of numerous "countries" which in turn were divided into units ruled by murderous petty chieftains many of whom harased kings and sought to become emperors themselves. So when kingdoms fell, re-organization of occupations, of victorious people filling up positions, are to be expected.
In the Pallava kingdom all these grades of officers (as in the tax-dept example given) were not 'brahmins'. There were many departments that managed various state affairs. Quite apparently they were getting their education from teachers. In the Pallava kingdom, the Bhatta was a teacher, just like a present-day teacher.
I have no idea when the term bhatta came to refer to brahmins. But i suppose it is because of the nair gentry, and royal families that arose from them. There are quite some writings (inclding sadasivan's work) which mention that priests (imo just teachers not exactly priests) were brought in from tamilnadu to conduct ceremonies for them since the local namboodiris wud not conduct ceremonies for them (due to the 'low-caste' of nairs). These teachers were in all probability elevated to brahminhood by these 'royalty'.
I hear from some academic people that those who elevate one another, tend to be related in some form or the other.
Caste (occupation) roles have been ever changing. IMO, it is rather far-fetched to think that those who are using surnames like kulkarnis (karanams, accountants), bhattacharjee, mukherjee, bhargava, etc are the same people who professed these professions in ancient kingdoms. Esp given the fact that mughal rule did upset social conditions, a lot more than a hindu kingdom defeating another hindu kingdom.
The framework of "caste" (ocupational categorzation) is ancient. Caste names may be old. However, the people that constituted a "caste" have always been changing.