The companion book "Fantastic Beasts and where to Find Them" notes that Newt Scamander spent several years working for the Office for House-Elf Relocation. Presumably this is a department that allocates and reassigns House Elves who need a new owner, perhaps when their current owner dies without having an heir.
After two years at the Office for House-Elf Relocation, years he describes as “tedious in the extreme,”...
The (alas non-canon) Wizarding World of Harry Potter exhibition also features a House-Elf Placement Agency, a company devoted to matching House-elves to families in need of domestic help. History doesn't record if they only place 'free' elves or whether they also match 'owned' elves with new masters.
