In-medium masses of the $1S$ and $1P$ states of heavy quarkonia are investigated in the magnetized asymmetric nuclear medium, accounting for the Dirac sea effects, using a combined approach of chiral effective model and QCD sum rule method. Masses are calculated from the in-medium scalar and twist-2 gluon condensates, calculated within the chiral model. The gluon condensate is simulated through the scalar dilaton field, $\ensuremath{\chi}$ introduced in the model through a scale-invariance breaking logarithmic potential. Contribution of the Dirac sea is incorporated through the nucleonic tadpole diagrams. Treating the scalar fields as classical, the dilaton field, $\ensuremath{\chi}$, the isoscalar nonstrange $\ensuremath{\sigma}(\ensuremath{\sim}(⟨\overline{u}u⟩+⟨\overline{d}d⟩))$, strange $\ensuremath{\zeta}(\ensuremath{\sim}⟨\overline{s}s⟩)$ and isovector $\ensuremath{\delta}(\ensuremath{\sim}(⟨\overline{u}u⟩\ensuremath{-}⟨\overline{d}d⟩))$ fields, are obtained by solving their coupled equations of motion as derived from the chiral model Lagrangian. The effects of magnetic field are incorporated through the Dirac sea as well as the Landau energy levels of the protons, and the anomalous magnetic moments of the nucleons. The scalar fields modify appreciably with magnetic field due to the Dirac sea contribution. In-medium masses of the charmonium and bottomonium ground states are observed to have significant modifications with magnetic field due to the effects of (inverse) magnetic catalysis. In presence of an external magnetic field, there is mixing between the longitudinal component of the vector and the pseudoscalar mesons (PV mixing) in both quarkonia sectors, leading to a rise (drop) of the masses of $J/{\ensuremath{\psi}}^{||}({\ensuremath{\eta}}_{c})$ and ${\mathrm{\ensuremath{\Upsilon}}}^{||}(1S)({\ensuremath{\eta}}_{b})$ states. These might show in the experimental observables, e.g., the dilepton spectra in the noncentral, ultrarelativistic heavy ion collision experiments at RHIC and LHC, where the produced magnetic field is huge.