In order to understand how cations affect the structural changes and enzyme activity of Lipase B from Candida antarctica, we performed all-atom molecular dynamics simulations of CALB in four types of ionic liquids (ILs) with varying sizes of imidazolium cations and correlated these results with the experimentally determined CALB activity. The imidazolium cations under study differ in the alkyl tail length in the following order: [Emim](+) < [Bmim](+) < [Hmim](+) < [Omim](+). We observed that the best enzyme activity and structural stability of CALB are obtained in [Bmim][TfO] and [Hmim][TfO]. In contrast, in [Emim][TfO], bonding of [TfO](-) to LYS-290 disrupts the interactions between LYS-290 and ILE-285, which leads to a closed catalytic gate conformation with low accessibility of substrates to the catalytic triad. In [Omim][TfO], strong hydrophobic interactions between [Omim](+) and LEU-278 result in a significant loss of the secondary structure of the α-10 helix and cause the exposure of the catalytic triad to ILs, which affects the stability of the catalytic triad and consequently deteriorates the enzyme activity. Overall, our study indicates that a high ion coordination number ([Emim][TfO]) or the presence of a long hydrophobic tail ([Omim][TfO]) can facilitate ion-protein interactions that cause structural distortions and a decrease in CALB enzyme activity in ILs.