Thank you for the information and your question. You don't say what State you rent in so I cannot discuss the time line and rules under your State law for the refunding of security deposits. If you want to provide your State where you rent after you receive my answer, then I can provide that information.
But, in general, in order for a landlord to either take an offset from a security deposit or to file suit for damages over the amount of the security deposit, they must be able to prove to the court that the damages were caused by the tenant and that the repairs/replacement was reasonably necessary to bring the unit back into the condition it was in before it was damaged. Normal wear and tear is not chargeable to the tenant and also repairs, as mentioned, must be reasonable necessary. There is no hard fast rule as to whether or not a complete replacement of a carpet versus patching it, or professionally cleaning it, is chargeable to the tenant. It is a case by case basis, depending on the facts.
It would be helpful to you if you have photos or a walk through from when you rented the unit that showed the carpet's condition and if that condition was already worn down. Otherwise, you would have to testify to the facts and provide any photos you do have to rebut any evidence that the landlord might present should this go to court.
Please feel free to ask for clarification if needed. Or, provide your State so I can give you the deadline, etc., for your landlord to refund your security deposit or offset notice to you.