Heavy quark threshold effects in two-loop order in quantum chromodynamics