Selling the house does not end the lease or require tenants to move. The buyer takes the property subject to the lease and gets the same rights to collect rent and enforce it.
Within 21 calendar days after your ownership ends, California gives you two choices for the security deposit. You can transfer what remains after lawful deductions to the buyer and notify the tenant by personal delivery or first-class mail. The notice must say the deposit was transferred, identify any claims against it and the amount transferred, and give the buyer’s name, address, and phone number. Or you can return what remains to the tenant with an itemized accounting. If these steps are skipped, the buyer can share liability for the deposit.
The new owner must give tenants its contact and rent-payment information within 15 days. We can talk through the lease and deposit with you as part of the handoff.