The production mechanism of quarkonia states in hadronic collisions is still to be understood by the scientific community. In high-multiplicity p þ p collisions, underlying event observables are of major interest. The multiparton interactions (MPIs) are underlying event observables, in which several interactions occur at the partonic level in a single p þ p event. This leads to dependence of particle production on event multiplicity. If the MPI occurs in a harder scale, there will be a correlation between the yield of quarkonia and total charged-particle multiplicity. The ALICE experiment at the LHC in p þ p collisions at ffiffi ffi s p ¼ 7 and 13 TeV has observed an approximate linear increase of relative J=ψ yield, ( dN J=ψ =dy hdN J=ψ =dyi ), with relative charged-particle multiplicity density, ( dN ch =dy hdN ch =dyi ). In our present work, we have performed a comprehensive study of the production of charmonia as a function of charged-particle multiplicity in p þ p collisions at LHC energies using the perturbative QCD-inspired multiparton interaction model, PYTHIA8 tune 4C, with and without the color reconnection scheme. A detailed multiplicity and energy-dependent study is performed to understand the effects of MPI on J=ψ production. The ratio of ψð2SÞ to J=ψ is also studied as a function of charged-particle multiplicity at LHC energies.