Hi Phoenix, and welcome!
It will vary depending upon which school or county you are interested in. Please bear in mind that most areas are turning up the heat on potentially fraudulent applications, so you will need to be totally honest and squeaky clean thoughout the process.
For Buckinghamshire grammars, your child can take the exam wherever you live, but you have to provide proof of the address to be used for the allocation of places a week before you get the results. (The system has changed this year - it used to be a week after the results were published.) That address must be your main residence, and if you are renting it and selling your original house you are likely to be asked to provide quite a lot of evidence that the move is permanent.
You do not actually have to live in Buckinghamshire to get a place, but you do have to be near enough to your preferred school, because places are allocated on distance. You can see what those distances might be here
. To gain a place at some of the most popular schools you need to live in the school's catchment area and live within no more than 4 - 5 miles of the school gates. If you live over 3 miles from the school gates and in catchment your child will get free transport to school.