The performance of open-system quantum annealing is adversely affected by thermal excitations out of the ground state. While the presence of energy gaps between the ground and excited states suppresses such excitations, error correction techniques are required to ensure full scalability of quantum annealing. Quantum annealing correction (QAC) is a method that aims to improve the performance of quantum annealers when control over only the problem (final) Hamiltonian is possible, along with decoding. Building on our earlier work [S. Matsuura et al., Phys. Rev. Lett. 116, 220501 (2016)], we study QAC using analytical tools of statistical physics by considering the effects of temperature and a transverse field on the penalty qubits in the ferromagnetic $p$-body infinite-range transverse-field Ising model. We analyze the effect of QAC on second ($p=2$) and first ($pgeq 3$) order phase transitions, and construct the phase diagram as a function of temperature and penalty strength. Our analysis reveals that for sufficiently low temperatures and in the absence of a transverse field on the penalty qubit, QAC breaks up a single, large free energy barrier into multiple smaller ones. We find theoretical evidence for an optimal penalty strength in the case of a transverse field on the penalty qubit, a feature observed in QAC experiments. Our results provide further compelling evidence that QAC provides an advantage over unencoded quantum annealing.