When you buy rentals is there a transfer of deposits?

What happens to the tenants deposits when a commercial property is transferred to a new owner? Do they get transferred to the buyer?

Yes. All deposits get transferred at closing as well as a proration of all prepaid rents and fees. Make sure this is clearly specified in your contract.

I usually take the deposit and prepayments as a credit at closing and transfer to my existing account.