The present application relates to the use of heterocyclic compounds of formula in which A represents substituted phenyl or a six-membered heterocycle containing one or two nitrogen atoms, B represents substituted phenyl or a five- or six-membered heterocycle containing up to three heteroatoms selected from oxygen, sulphur and nitrogen, and R3, R4 and Z have the meanings provided in the specification, for controlling animal pests which are encountered in agriculture, in horticulture, in forests, in gardens and leisure facilities and in the protection of stored products and of materials, to novel heterocyclic compounds, to processes for their preparation and to intermediates for preparing the heterocyclic compounds.