We present time-series photometry of 21 nearby type II Cepheids in the near-infrared J, H, and Ks passbands. We use this photometry, together with the Third Gaia Early Data Release parallaxes, to determine for the first time period-luminosity relations (PLRs) for type II Cepheids from field representatives of these old pulsating stars in the near-infrared regime. We found PLRs to be very narrow for BL Herculis stars, which makes them candidates for precision distance indicators. We then use archival photometry and the most accurate distance obtained from eclipsing binaries to recalibrate PLRs for type II Cepheids in the Large Magellanic Cloud (LMC). Slopes of our PLRs in the Milky Way and in the LMC differ by slightly more than 2{sigma} and are in a good agreement with previous studies of the LMC, Galactic bulge, and Galactic globular cluster type II Cepheids samples. We use PLRs of Milky Way type II Cepheids to measure the distance to the LMC, and we obtain a distance modulus of 18.540+/-0.026(stat.)+/-0.034(syst.)mag in the W_JK_ Wesenheit index. We also investigate the metallicity effect within our Milky Way sample, and we find a rather significant value of about -0.2mag/dex in each band meaning that more metal-rich type II Cepheids are intrinsically brighter than their more metal-poor counterparts, in agreement with the value obtained from type II Cepheids in Galactic globular clusters. The main source of systematic error on our Milky Way PLRs calibration, and the LMC distance, is the current uncertainty of the Gaia parallax zero-point.