Hello Anupama,
Like Preetam Deshpande mentioned, this practice isn't legal and could land your company into legal trouble if anyone goes to court. Many small IT companies in Andhra Pradesh who use this practice for retention may not be paying any interest over the deducted amount - whatever the quantum. Please note that I am not disputing your intent here, only the 'how' part.
Like Pon suggested, try to include this within the Appointment Letter itself in the form of a Retention Bonus. To explain, suppose a hiree wants a CTC of 6 L p.a., you can negotiate for 5.5 L for the monthly payout in the form of salary AND 50K to be payable after 6 months or 1 year as a Retention Bonus - whatever duration you have in mind. If the employee leaves before that period, then he/she stands to lose it - which will have to be mentioned clearly in the Offer/Appointment Letter. This is what Pon meant. That way, you neither have to make any deductions - complicating matters - and also maintain cordial relations with the employees. However, please note that, like every step/measure in HR, this too has its own set of downsides. You need to be on the watch around the time when the employee gets the Bonus - chances of an employee quitting AFTER taking the Bonus could be there. And, please ensure the Bonus IS PAID WITHOUT DELAY as soon as it's due - many companies which have the Retention Bonus scheme delay this payment leading to unwarranted HR situations.
All said and done, there's no replacement for long-term Good HR Practices - which minimize such situations. But if you are looking for an ideal situation that NO employee will LEAVE, those days are gone.
All the Best.
Regards,
TS