If the moon depends on the magnetic field of the planet to shield it from stellar wind and cosmic ray, it should probably orbit the planet at a distance somewhere between 5 and 20 planetary radii.
Rene Heller and Roy Barnes, in "Exomoon Habitability Constrained by Illumination and Tidal Heating", 2013, created the concept of a "habitable edge" of a gas giant planet.
The habitable edge is a distance that an exomoon has to orbit from a gas giant to avoid excessive tidal heating. Tidal interactions between a giant planet and a large moon of it cause tidal heating of the inside of the moon, which works its way to the surface of the moon.
If the tidal interactions between the planet and the moon are too strong, the tidal heating of the moon's surface can be fatal to life on the moon. Too much tidal heating can turn a moon's surface into a volcanic hell like that of Io. And somewhat less tidal heating can be enough to cause a runaway greenhouse effect on the moon.
In a runaway greenhouse effect the surface of a world becomes hot enough that too much of the surface water turns into water vapor, which is a strong greenhouse gas, which thus heats up the surface more, evaporating more water which increases the greenhouse effect, until the surface of the world is so hot that water is now vapor and there is no surface water life. By the current scientific definition of a habitable world, a world without liquid surface water is not habitable.
The closer a moon orbits around a planet, the greater the tidal effects, including tidal heating, will be.
So Heller and Barnes coined the concept of a habitable edge in "Exomoon Habitability Constrained by Illumination and Tidal Heating". A potentially habitable exomoon will have to orbit a giant planet farther than the habitable edge to retain liquid surface water.
It may be noted that if a giant planet and its moon orbit within the habitable zone of their star, they will get sufficient radiation from the star to be warm enough for liquid water and life, and thus even a comparatively small amount of heat from tidal heating might be enough to give the moon a runaway greenhouse.
But if a moon orbits around a rogue gas giant interstellar space light years from the nearest star, all of the moon's heat will have to come from tidal heating and decay of radioactive elements, and the moon can take a lot more tidal heating.
Thus the distance of the habitable edge of a gas giant planet depends in part on how much radiation, if any, the planet receives from its star.
Most gas giant planets are expected to have very strong magnetic fields which interact with charged particles from the stellar wind and cosmic rays. Thus if a potentially habitable moon orbits in the radiation belt of its planet where many charged particles are trapped, it is likely to decrease the probability of the moon having life.
On the other hand, if the potentially habitable moon has no magnetic field of its own to deflect charged particles, orbiting within the magnetic field of its planet can protect the moon from stellar wind and cosmic rays.
So orbiting within the magnetic field of its planet can be either detrimental or beneficial to the habitability of a moon.
In "Magnetic Shielding of Exomoons Beyond the Circumplanetary Habitable Edge", 2013, Rene Heller and Jorge Zuluaga modeled the evolution of the magnetic field of gas giant planets in relation to their moons.
The abstract says:
With most planets and planetary candidates detected in the stellar habitable zone (HZ) being super11 Earths and gas giants, rather than Earth-like planets, we naturally wonder if their moons could be habitable. The first detection of such an exomoon has now become feasible, and due to observational biases it will be at least twice as massive as Mars. But formation models predict moons can hardly be as massive as Earth. Hence, a giant planet’s magnetosphere could be the only possibility for such a moon to be shielded from cosmic and stellar high-energy radiation. Yet, the planetary radiation belt could also have detrimental effects on exomoon habitability. We here synthesize models for the evolution of the magnetic environment of giant planets with thresholds from the runaway greenhouse
(RG) effect to assess the habitability of exomoons. For modest eccentricities, we find that satellites around Neptune-sized planets in the center of the HZ around K dwarf stars will either be in an RG state and not be habitable, or they will be in wide orbits where they will not be affected by the planetary magnetosphere. Saturn-like planets have stronger fields, and Jupiter-like planets could coat close-in habitable moons soon after formation. Moons at distances between about 5 and 20 planetary radii from a giant planet can be habitable from an illumination and tidal heating point of view, but still the planetary magnetosphere would critically influence their habitability.
I think that The two things to note from the abstract and article are:
Moons at distances between about 5 and 20 planetary radii from a giant planet can be habitable from an illumination and tidal heating point of view, but still the planetary magnetosphere would critically influence their habitability.
But formation models predict moons can hardly be as massive as Earth.
So your habitable moon should probably orbit its planet at a distance somewhere between 5 and 20 planetary radii.
And models of the formation of moons indicate that giant planets will not have moons as mass as the Earth. So either you will have to make your habitable moon much smaller than Earth, but still large enough to be habitable, or else ignore the models of the formation of moons and hope that it actually is possible for moons to be as massive as the Earth.
Going back to Heller and Barnes: "Exomoon Habitability Constrained by Illumination and Tidal Heating", they discuss the possible formation of massive moons around exoplanets despite models of moon formation indicating that it is very unlikely for moons to form that are as massive as Earth.
In section 2.1 on page 4 they write:
Ways to circumvent the impasse of insufficient satellite mass are the gravitational capture of massive moons (Debes &
Sigurdsson 2007; Porter & Grundy 2011; Quarles et al. 2012), which seems to have worked for Triton around Neptune (Goldreich et al. 1989; Agnor & Hamilton 2006); the capture of Trojans (Eberle et al. 2011); gas drag in primordial circumplanetary envelopes (Pollack et al. 1979); pull-down capture trapping temporary satellites or bodies near the Lagrangian points into stable orbits (Heppenheimer & Porco 1977; Jewitt & Haghighipour 2007); the coalescence of moons (Mosqueira & Estrada 2003); and impacts on terrestrial planets (Canup 2004; Withers & Barnes 2010; Elser et al. 2011). Such moons would correspond to the irregular satellites in the Solar System, as opposed to regular satellites that form in situ. Irregular satellites often follow distant, inclined, and often eccentric or even retrograde orbits about their planet (Carruba et al. 2002). For now, we assume that Earth-mass extrasolar moons – be they regular or irregular – exist.
Thus they discuss a number of ways that Earth mass moons might form, citing a number of scientific articles.
A decade later, there are still no confirmed exomoons, but the numerous candidates include several with masses equal to Earth or even much greater.
I note that the moon will not need the protection of a magnetic field to retain its atmosphere. An Earth mass moon would be massive enough that Jeans escape of the atmosphere would be very slow, and the stripping away of an atmosphere by stellar wind is even slower.
An Earth mass moon could generate its own magnetic field. I think a planetary magnetic field is generated by convection currents in a liquid layer of a world's interior, and an Earth mass exomoon should be massive enough for that.