The automatic lock of the workstation upon smart card removal is managed by the Windows system policies.

Generally, in an enterprise environment, these policies are managed by an administrator within the global group policies. These group policies are normally mandatory for every workstation within the domain. It is also possible to set the required policies only for a local workstation. Setting the local policies are useful for demo or testing cases and for standalone and non-domain computers. For an auto-lock upon smart card removal it is necessary to enable two Windows policy features like described below:

Setting Group Policies


Source Article

Setting Local Policies