We derive the two-loop effective action for covariantly constant field strength of pure Yang-Mills theory in the presence of an infrared scale. The computation is done in the framework of the worldline formalism, based on a generalization procedure of constructing multiloop effective actions in terms of the bosonic worldline path integral. The two-loop beta-function is correctly reproduced. This is the first derivation in the worldline formulation, and serves as a nontrivial check on the consistency of the multiloop generalization procedure in the worldline formalism.