You left out something very important from this question: In what culture at what time?
There are many cultures where women keep their family names. There are many cultures to this day that do not use family names (Myanmar, Iceland). How family names came into use varies from culture to culture down time. Family names are BC in China.
If I assume you mean Western Europe and North America, I also have to assume you mean British Isles and France and the Lowlands, because Hispanic women kept their family names at many eras.
First, the term "last name" is not useful. If it's just an eke-name/byname/surname/patronymic, then it's never used by a wife. In some Euro cultures at some times, the last name is the personal name. So let's say we are talking about inherited family names that don't change from one generation to the next, no matter where they are located.
Family names generally started at the top, with noble families adopting them, often from a title. The monarchs of France never had a family name. Dynastic references like "the Bourbons" were not a family name. A few families in Italy and Scotland will try to claim great ancientness for the use of family names. However, the use of family names as such, not just meaning "the guy who lives at this estate," becomes an upper class habit in the 1300-1450, again depending where you are.
It was already well established in English law that a woman who married had no legal identity (for suits and contracts) apart from her husband, so her taking his name, becoming Mrs. George Paston, was an expression of this.
Commoners having fixed family names took longer. As a special report shows, at the start of the 20th C, the common Irishman did not view his family name as fixed. The immigration authorities would have a different attitude. The Scandinavian victim of Jack the Ripper had no family name until she emigrated to the UK. On the whole, in England at least they were widespread by the Renaissance, though directories of London may show a man known as either Aunseremaker (clockmaker) or another surname. In other countries they had to be imposed on the populace for record-keeping in the 1800's (German Jews 4X). Among the dancers listed in Negro, 1604, all the upper class have family names, many of the others have only origin surnames, and married women keep their family name but add their husband's.
USA and Canada just follow English habit.
Source: Ingraham, People's Names, McFarland, 1997
Ditto, People's Names Around the World Since 4500 BC, in ms.
EDIT
Bardsley, Our English Surnames
Ditto, The Romance of the London Directory
Bètencourt, Noms feodaux ou noms de ceux qui ont tenu fiefs en France dans les provinces ... depuis le XIIth siecle jusque vers le milieu du XVIIIth
Ewen, AHistory of Surnames in the British Isles
Fucilla, Our Italian Surnames
Louie, Chinese-American Names
Matheson, Special Report on Surnames in Ireland, 1894
Ditto, Varieties and Synonyms of Surnames and Christian Names in Ireland
Negro, Nuove inventioni di balli, 1604
Paterson, Scottish Surnames, 1866
Scott, The Burman His Life and Notions
Weekley, The Romance of Names