  Superfluid $^3$He-B possesses three locally stable vortices known as a
normal-core vortex ($o$-vortex), an A-phase-core vortex ($v$-vortex), and a
double-core vortex ($d$-vortex). In this work, we study the effects of a
magnetic field parallel or perpendicular to the vortex axis on these structures
by solving the two-dimensional Ginzburg-Landau equation for two different sets
of strong coupling correction. The energies of the $v$- and $d$-vortices have
nontrivial dependence on the magnetic field. As a longitudinal magnetic field
increases, the $v$-vortex is energetically unstable even for high pressures and
the $d$-vortex becomes energetically most stable for all possible range of
pressure. For a transverse magnetic field the energy of the $v$-vortex becomes
lower than that of the $d$-vortex in the high pressure side. In addition, the
orientation of the double cores in the $d$-vortex prefers to be parallel to the
magnetic field at low pressures, while the $d$-vortex with the double cores
perpendicular to the magnetic field is allowed to continuously deform into the
$v$-vortex by increasing the pressure.
