We show that when the QCD axion is directly coupled to quarks with c_{i}/f∂_{μ}aq[over ¯]_{i}γ^{μ}γ^{5}q_{i}, such as in Dine-Fischler-Srednicki-Zhitnitsky models, the dominant production mechanism in the early Universe at temperatures 1 GeV≲T≲100 GeV is obtained via q_{i}q[over ¯]_{i}↔ga and q_{i}g↔q_{i}a, where g are gluons. The production of axions through such processes is maximal around T≈m_{i}, where m_{i} are the different heavy quark masses. This leads to a relic axion background that decouples at such temperatures, leaving a contribution to the effective number of relativistic degrees of freedom, which can be larger than the case of decoupling happens the electroweak phase transition, ΔN_{eff}≲0.027. Our prediction for the t quark is 0.027≤ΔN_{eff}≤0.036 for 10^{6} GeV≲f/c_{t}≲4×10^{8} GeV and for the b quark is 0.027≤ΔN_{eff}≤0.047 for 10^{7} GeV≲f/c_{b}≲3×10^{8} GeV. For the c quark the window can only be roughly estimated as 0.027<ΔN_{eff}≲O(0.1), for f/c_{c}≲(2-3)×10^{8} GeV, since axions can still be partially produced in a regime of strong coupling, when α_{s}≳1. These contributions are comparable to the sensitivity of future CMB S4 experiments, thus opening an alternative window to detect the axion and to test the early Universe at such temperatures.