A heterocyclic compound is represented by formula (I):in which R2 represents a C1-C6 alkyl group optionally having one or more halogen atoms, n is 0, R3 represents a C1-C6 chain hydrocarbon group optionally having one or more substituents selected from Group B, q is 0, Het represents a group represented by the formulae Het 1 or Het 2, A1 represents a nitrogen atom, and Q2 represents an oxygen atom. The compound has excellent efficacy for controlling harmful arthropods. A composition is provided which contains the compound of formula (I) and one or more additional ingredients.