  We investigate the behavior of the pseudo-critical temperature of $N_f = 2+1$
QCD as a function of a static magnetic background field for different values of
the pion mass, going up to $m_\pi \simeq 660$ MeV. The study is performed by
lattice QCD simulations, adopting a stout staggered discretization of the
theory on lattices with $N_t = 6$ slices in the Euclidean temporal direction;
for each value of the pion mass the temperature is changed moving along a line
of constant physics. We find that the decrease of $T_c$ as a function of $B$,
which is observed for physical quark masses, persists in the whole explored
mass range, even if the relative variation of $T_c$ appears to be a decreasing
function of $m_\pi$, approaching zero in the quenched limit. The location of
$T_c$ is based on the renormalized quark condensate and its susceptibility;
determinations based on the Polyakov loop lead to compatible results. On the
contrary, inverse magnetic catalysis, i.e. the decrease of the quark condensate
as a function of $B$ in some temperature range around $T_c$, is not observed
when the pion mass is high enough. That supports the idea that inverse magnetic
catalysis might be a secondary phenomenon, while the modifications induced by
the magnetic background on the gauge field distribution and on the confining
properties of the medium could play a primary role in the whole range of pion
masses
