The production of $\Lambda$ baryons and ${\rm K}^{0}_{\rm S}$ mesons (${\rm V}^{0}$ particles) was measured in p-Pb collisions at $\sqrt{s_{\rm NN}} = 5.02$ TeV and pp collisions at $\sqrt{s} = 7$ TeV with ALICE at the LHC. The production of these strange particles is studied separately for particles associated with hard scatterings and the underlying event to shed light on the baryon-to-meson ratio enhancement observed at intermediate transverse momentum ($p_{\rm T}$) in high multiplicity pp and p-Pb collisions. Hard scatterings are selected on an event-by-event basis with jets reconstructed with the anti-$k_{\rm T}$ algorithm using charged particles. The production of strange particles associated with jets $p_{\rm T,\;jet}^{\rm ch}>10$ and $p_{\rm T,\;jet}^{\rm ch}>20$ GeV/$c$ in p-Pb collisions, and with jet $p_{\rm T,\;jet}^{\rm ch}>10$ GeV/$c$ in pp collisions is reported as a function of $p_{\rm T}$. Its dependence on angular distance from the jet axis, $R({\rm V}^{0},\;{\rm jet})$, for jets with $p_{\rm T,\;jet}^{\rm ch}>10$ GeV/$c$ in p-Pb collisions is reported as well. The $p_{\rm T}$-differential production spectra of strange particles associated with jets are found to be harder compared to that in the underlying event and both differ from the inclusive measurements. In events containing a jet, the density of the ${\rm V}^{0}$ particles in the underlying event is found to be larger than the density in the minimum bias events. The $\Lambda/{\rm K}^{0}_{\rm S}$ ratio associated with jets in p-Pb collisions is consistent with the ratio in pp collisions and follows the expectation of jets fragmenting in vacuum. On the other hand, this ratio within jets is consistently lower than the one obtained in the underlying event and it does not show the characteristic enhancement of baryons at intermediate $p_{\rm T}$ often referred to as "baryon anomaly" in the inclusive measurements.