The deposit belongs to the tenant until the landlord has a lawful reason to keep part of it. After move-out, the landlord returns the deposit, minus any allowed deductions, usually with an itemized list of what was deducted and why.
Security deposits are heavily regulated, and the rules are set by state (and sometimes city) law: how much a landlord may collect, whether it must be held in a separate or interest-bearing account, what counts as normal wear and tear, and how many days the landlord has to return it. Those limits and deadlines vary widely, so check the rules where the property is.
The best protection for both sides is a documented condition record: a move-in inspection with photos, signed by the tenant, and a matching move-out inspection. Deductions backed by that record are much easier to defend.
Free resource: Move-in / move-out inspection checklist.