The production of strange hadrons (K$^{0}_{\rm S}$, $\Lambda$, $\Xi^{\pm}$, and $\Omega^{\pm}$), baryon-to-meson ratios ($\Lambda/{\rm K}^0_{\rm S}$, $\Xi/{\rm K}^0_{\rm S }$, and $\Omega/{\rm K}^0_{\rm S}$), and baryon-to-baryon ratios ($\Xi/\Lambda$, $\Omega/\Lambda$, and $\Omega/\Xi$) associated with jets and the underlying event were measured as a function of transverse momentum ($p_{\rm T}$) in pp collisions at $\sqrt{s} = 13$ TeV and p-Pb collisions at $\sqrt{s_{\rm NN}} = 5.02$ TeV with the ALICE detector at the LHC. The inclusive production of the same particle species and the corresponding ratios are also reported. The production of multi-strange hadrons, $\Xi^{\pm}$ and $\Omega^{\pm}$, and their associated particle ratios in jets and in the underlying event are measured for the first time. In both pp and p-Pb collisions, the baryon-to-meson and baryon-to-baryon yield ratios measured in jets differ from the inclusive particle production for low and intermediate hadron $p_{\rm T}$ (0.6$-$6 GeV/$c$). Ratios measured in the underlying event are in turn similar to those measured for inclusive particle production. In pp collisions, the particle production in jets is compared with PYTHIA 8 predictions with three colour-reconnection implementation modes. None of them fully reproduces the data in the measured hadron $p_{\rm T}$ region. The maximum deviation is observed for $\Xi^{\pm}$ and $\Omega^{\pm}$, which reaches a factor of about six. In p-Pb collisions, there is no significant event-multiplicity dependence for particle production in jets, in contrast to what is observed in the underlying event. The presented measurements provide novel constraints on hadronisation and its Monte Carlo description. In particular, they demonstrate that the fragmentation of jets alone is insufficient to describe the strange and multi-strange particle production in hadronic collisions at LHC energies.