Because the term of your original lease expired and you are currently in a month-to-month tenancy, you no longer have the protection of a lease. Thus, if the home is sold before you move out, you would need to vacate the property by the end of the month. You would still be entitled to a refund of your security deposit (aside from any portions rightfully withheld for damages exceeding normal wear and tear); which would be owed by the new owner. And the condition of the property at your time of move in would still be relevant in determining what if any damages are attributable to you.
I hope this information helps answer your question(s).
~ Kem Eyo
The above answer is a general explanation of legal rights and procedures. It does not constitute legal advice. Nor does it establish an attorney-client relationship between the individual posting the question and the attorney providing the answer.