Observations of infrared fine-structure lines provide direct information on the metallicity and ionization structure of H II regions and indirectly on the hardness of the radiation field ionizing these nebulae. We have analyzed a sample of Galactic and Magellanic Cloud H II regions observed by the Infrared Space Observatory (ISO) to examine the interplay between stellar content, metallicity and the ionization structure of H II regions. The observed [S IV] 10.5/[S III] 18.7 mum and[Ne III] 15.5/[Ne II] 12.8 mum line ratios are shown to be highly correlated over more than two orders of magnitude. We have compared the observed line ratios to the results of photoionization models using different stellar energy distributions. The derived characteristics of the ionizing star depend critically on the adopted stellar model as well as the (stellar) metallicity. We have compared the stellar effective temperatures derived from these model studies for a few well-studied H II regions with published direct spectroscopic determinations of the spectral type of the ionizing stars. This comparison supports our interpretation that stellar and nebular metallicity influences the observed infrared ionic line ratios. We can explain the observed increase in degree of ionization, as traced by the [S IV]/[S III] and[Ne III]/[Ne II] line ratios, by the hardening of the radiation field due to the decrease of metallicity. The implications of our results for the determination of the ages of starbursts in starburst galaxies are assessed.