Call your local renters association they can usually give you this info for free where an attorney may want a fee for consulting you (hey in these times everybode is try to get paid). Or the state real estate division.
This issue varies from state to state. Not only to what a security deposit can be used for but also the amount of notice needed to terminate even a month to month lease.
I would suggest you contact a landlord/tenant attorney and ask him or her this question. You can probably get the answer over the phone for free. I would also suggest you have a peaceful conversation with your landlord and hope for the best.
I am not an attorney and cannot give legal advise, however, my humble take on it is as follows: You stated that you are a "month to month" tenant, I assume that this means there is no written agreement. If so it becomes a "gray" area and hard to give a definitive answer. Theoretically if you are month to month and your rent is paid in full prior to the date that you move out, also assuming you did not damage the apartment, I believe you should be entitled to get your security deposit back. Your landlord may disagree with my perspective and if so you may have a legal battle not worth fighting because the expense would probably be greater than your security deposit anyway.
Madison Estates & Properties, Inc.
Office: (718) 645-1665
Also, you can read through your lease and it will stipulate the amount of notice the landlord needs.