According to the current version of Nomenclature of Organic Chemistry – IUPAC Recommendations and Preferred Names 2013 (Blue Book), the retained names “aniline” and “phenol” are preferred IUPAC names (PINs). Parent structures having retained names are called functional parent compounds.
For both retained names, substitution is permitted at any position. However, substitution of a functional parent compound is limited to substituent groups cited as prefixes in accordance with the seniority of the functional group that is explicitly expressed or implied in the functional parent compound name. (In systematic names, the presence of this characteristic group would normally be expressed as a suffix.)
P-220.127.116.11.1 Substitution rules for Type 2a retained names
Type 2a retained names include functional parent compounds whose name expresses or implies a characteristic group expressed as suffix in systematic names.
P-18.104.22.168.1.1 Substitution by substituent groups, expressed as prefixes, having a lower seniority than that denoted by the suffix is allowed.
P-22.214.171.124.1.2 The senior characteristic group or functional class name must be
expressed in the name.
Therefore, the correct name for the compound given in the question is “2-aminophenol” (not “2-hydroxyaniline”) since hydroxy compounds are senior to amines.