Context. The 16 Cygni system is composed of two solar analogues with similar masses and ages. A red dwarf is in orbit around 16 Cygni A, and 16 Cygni B hosts a giant planet. The abundances of heavy elements are similar in the two stars, but lithium is much more depleted in 16 Cygni B than in 16 Cygni A, by a factor of at least 4.7. Aims. The interest of studying the 16 Cygni system is that the two star have the same age and the same initial composition. The differences currently observed must be due to their different evolution, related to the fact that one of them hosts a planet while the other does not. Methods. We computed models of the two stars that precisely fit the observed seismic frequencies. We used the Toulouse Geneva Evolution Code (TGEC), which includes complete atomic diffusion (including radiative accelerations). We compared the predicted surface abundances with the spectroscopic observations and confirm that another mixing process is needed. We then included the effect of accretion-induced fingering convection. Results. The accretion of planetary matter does not change the metal abundances but leads to lithium destruction, which depends upon the accreted mass. A fraction of the Earth's mass is enough to explain the lithium surface abundances of 16 Cygni B. We also checked the beryllium abundances. Conclusions. In the case of accretion of heavy matter onto stellar surfaces, the accreted heavy elements do not remain in the outer convective zones, but are mixed downwards by fingering convection induced by the unstable μ-gradient. Depending on the accreted mass, this mixing process may transport lithium down to its nuclear destruction layers and lead to an extra lithium depletion at the surface. A fraction of the Earth's mass is enough to explain a lithium ratio of 4.7 in the 16 Cygni system. In this case beryllium is not destroyed. Such a process may be frequent in planet-hosting stars and should be studied in other cases in the future.