The chemical reactions and pathways resulting in the formation of oxazole or thiazole, five-membered heterocyclic ring structures containing an oxygen and a sulfur, respectively, in the 1-position and a nitrogen in the 3-position.