The odor of mothballs made with paradichlorobenzene (now rare) will dissipate completely with air turnover. The odor of mothballs that made with naphtha will be harder to remove, but I'd second the use of ozone. The critical part of the process is to locate any solids (ball, fragment of ball, or crystal) and remove them. They could be behind cabinet dawers, on closet shelves, under baseboards...
PS: If the smell is from a naphtha based pest control application, you might never get it out of the carpet. We stopped referring a pest control company that we'd recommended for years when they went to a naphtha based product. We can't get the odor of their product out of rugs in a plant wash environment.