It is unfortunate but there are some cases in which a landlord will wrongly keep a security deposit. However there are also many cases which the landlord may keep all or part of your security deposit. It is vital that you know and understand your lease so that you may avoid misunderstandings.
The most common terms that involve a landlord being able to keep your deposit is overdue rent. If at the time of your moving you have rent that is still due, the landlord has the right to keep the deposit to recover the rent owed to them. However, they may only keep the portion to cover the rent. If the deposit is more than what is owed, the remainder amount must be returned to renter.
Another circumstance when your landlord may keep all or part of your deposit is if there are damages to the property that are not considered normal wear and tear. For example, if one of the occupants of the home gets mad and punches a hole in the wall, the landlord has every right to keep enough of your deposit to cover fixing the hole. A way to avoid this is to go around the house and make small repairs before they view the house upon you leaving. The better way to avoid this is to be meticulous about taking care of the property you are renting. Many landlords will be surprised if you do so because too many tenants will leave a messy home for them to clean up. Plus, this allows you to have a great reference for future renting or buying.
A third example is if you own any pets and you have a pet agreement included in your lease. You might of paid a pet deposit that was an extra fee on top of the other deposit that was paid upon moving in. Often these extra pet deposits are for repairing any damage, smell, etc, left by pets which is inevitable. However, if too much damage is done to the house by the pets, the repairs may eat into your security deposit. Often the pet deposit is nonrefundable even if your pets were well behaved. Therefore, do not lose even more money by letting your pets run crazy.
Overall, take care of your rental property and pay your rent on time and you should have no issues with getting your security deposit back.
Good Video also describing how not to lose your deposit