They passed through inheritance; one could look upon the Hogwarts Principalship as something of an inheritance. Since Hogwarts isn't owned by any one person, the Headmaster comes closest. One would imagine once the elves arrived, back in the early days of Hogwarts, it was established their ownership would pass as such.