Old pet stains are normally the culprit. It is impossible to remove urine by normal cleaning and while there may be no visible evidence of a stain, the urine oxidises and reacts with carpet to create amino acids which work into the fibres and even into the under floor. When moisture is present, for example after cleaning or in high humidity, the uric acid crystals absorb water and exude an ammonia gas.
Generally you will not smell the pet stains after they have dried and you may shocked by the smell after cleaning. Think of these dry pet stains as powdered milk, it remains in powered form until water is added, reactivating the odour.
Professional cleaners have powerful oxidizing agents that can eliminate the source of the odour, which can sometimes involve lifting the carpet and treating the subfloor.
In a large number of instances the odour cannot be treated with one clean, it may require a number of specialized treatments and visits.
It should be noted that if the animal is still in the house it will invariably re-mark it’s territory and the odour will return.