As a general rule, a dwelling is no longer your main residence once you stop living in it. However, in some cases you can choose to have a dwelling treated as your main residence for capital gains tax (CGT) purposes even though you no longer live in it.
Warning: You cannot make this choice for the period before dwelling first becomes your main residence.
This choice needs to be made only for the income year that the CGT event happens to the dwelling – for example, the year that you enter into a contract to sell it.
If you make this choice, you cannot treat any other dwelling as your main residence for that period (except for a limited time if you are changing main residences refer to issue 3).
If you do not use it to produce income (for example, you leave it vacant, or use it as a holiday home) you can treat the dwelling as your main residence for an unlimited period after you cease living in it.
If you use the dwelling to produce income (for example, you rent it out or it is available for rent) you can choose to treat it as your main residence for up to six years after you cease living in it.
If you rent out the dwelling for more than six years, the ‘home first used to produce income’ (refer to issue 4) rule may apply, which means you are taken to have acquired the dwelling at its market value at the time you first used it to produce income.
If you are absent more than once during the period you own the home, the six year maximum period that you can treat it as your main residence while you use it to produce income applies separately to each period of absence.
Source: Treating a dwelling as your main residence after you move out