The influence of helium and argon impurities on the deuterium retention in tungsten is investigated by a numerical diffusion model, which treats diffusing depth profiles for deuterium and helium or argon in tungsten, taking into account the suggested effects of helium or argon. With helium, a helium nanobubble layer builds up at the surface of the sample, with depths higher than the penetration depth of the incident helium and deuterium ions. The nanobubbles form a porous network, which allows the release of trapped deuterium by surface recombination and diffusion through the pores to the surface. For argon, only a shallow layer of argon-induced defects exists, which also act as trapping sites for deuterium. A number of experiments with tungsten samples were conducted at the linear plasma device PSI-2 in support of the model. Helium and argon were admixed to deuterium plasma in ratios of up to 8% for otherwise similar exposure conditions. In addition, a variation of ion fluences was performed for investigation of the onset and evolution of the effects of impurities. The model shows that the influence on the deuterium retention both for helium nanobubbles as well as for argon-induced defects depends strongly on the ratio between the thickness of the helium- or argon-affected layer and the penetration depth of deuterium ions.