The production of K∗(892)0 and φ(1020) mesons in proton-proton (pp) and lead-lead (Pb-Pb) collisions at sNN = 5.02 TeV has been measured using the ALICE detector at the Large Hadron Collider (LHC). The transverse momentum (pT) distributions of K∗(892)0 and φ(1020) mesons have been measured at midrapidity (|y|<0.5) up to pT= 20 GeV/c in inelastic pp collisions and for several Pb-Pb collision centralities. The collision centrality and collision energy dependence of the average transverse momenta agree with the radial flow scenario observed with stable hadrons, showing that the effect is stronger for more central collisions and higher collision energies. The K∗0/K ratio is found to be suppressed in Pb-Pb collisions relative to pp collisions: this indicates a loss of the measured K∗(892)0 signal due to rescattering of its decay products in the hadronic phase. In contrast, for the longer-lived φ(1020) mesons, no such suppression is observed. The nuclear modification factors (RAA) of K∗(892)0 and φ(1020) mesons are calculated using pp reference spectra at the same collision energy. In central Pb-Pb collisions for pT > 8 GeV/c, the RAA values of K∗(892)0 and φ(1020) are below unity and observed to be similar to those of pions, kaons, and (anti)protons. The RAA values at high pT (>8 GeV/c) for K∗(892)0 and φ(1020) mesons are in agreement within uncertainties for sNN= 5.02 and 2.76 TeV.