There are several criteria for the numbering of locants. The most important simplified criteria for the numbering for substituted benzene compounds are:
- lower locants for the principal characteristic groups, which are expressed as a suffix or implied by the name of the functional parent compound (If there is a choice, the principal characteristic groups are assigned in accordance with the order of seniority of classes of compounds.)
- lower locants for prefixes
- lower locants for substituents cited first as a prefix in the name
The corresponding actual wording of the nomenclature rules (taken from Nomenclature of Organic Chemistry – IUPAC Recommendations and Preferred Names 2013 (Blue Book)) reads as follows:
P-14.4 NUMBERING
When several structural features appear in cyclic and acyclic compounds, low locants are assigned to them in the following decreasing order of seniority:
(…)
(c) principal characteristic groups and free valences (suffixes);
(…)
(f) detachable alphabetized prefixes, all considered together in a series of increasing numerical order;
(g) lowest locants for the substituent cited first as a prefix in the name;
(…)
The first compound given in the question has the functional parent compound phenol. The name ‘phenol’ implies the presence of the characteristic group $\ce{-OH}$. Since there are no other characteristic groups and low locants are assigned first to the principal characteristic group, the locant ‘1’ is assigned to the substituent group $\ce{-OH}$. Therefore, the systematic name for this compound is 3,4-dimethylphenol.

The second compound given in the question does not have any principal characteristic group – neither expressed as a suffix nor implied by the name of a functional parent compound. Therefore, low locants are assigned to the prefixes ‘chloro’, ‘methyl’, and ‘nitro’, all considered together as a set in a series of increasing numerical order. Thus, the systematic name for this compound is 2-chloro-1-methyl-4-nitrobenzene and neither ‘1-chloro-2-methyl-5-nitrobenzene’ nor ‘3-chloro-4-methyl-1-nitrobenzene’ since the locant set ‘1,2,4’ is lower than ‘1,2,5’ or ‘1,3,4’.
