Using the quantum chromodynamics (QCD) equation of state (EoS) from lattice calculations we investigate effects from QCD on primordial gravitational waves (PGWs) produced during the inflationary era. We also consider different cases for vanishing and nonvanishing lepton asymmetry where the latter one is constrained by cosmic microwave background experiments. Our results show that there is up to a few percent deviation in the predicted gravitational wave background in the frequency range around the QCD transition ($10^{-10}- 10^{-7}$~Hz) for different lattice QCD EoSs, or at larger frequencies for nonvanishing lepton asymmetry using perturbative QCD. Future gravitational wave experiments with high enough sensitivity in the measurement of the amplitude of PGWs like SKA, EPTA, DECIGO and LISA can probe these differences and can shed light on the real nature of the cosmic QCD transition and the existence of a nonvanishing lepton asymmetry in the early universe.