You can leave your job at any time but whenever that is after 1 month or 2years it is up to your employer to decide if he'll give you an NOC. There is no obligation - even after 2 years service.