We report on the discovery of the companion star to the millisecond pulsar J1342+2822B in the globular cluster M3. We exploited a combination of near-ultraviolet and optical observations acquired with the Hubble Space Telescope in order to search for the optical counterparts to the known millisecond pulsars in this cluster. At a position in excellent agreement with that of the radio pulsar J1342+2822B (M3B), we have identified a blue and faint object (mF275W approx 22.45) that, in the color-magnitude diagram of the cluster, is located in the region of He core white dwarfs. From the comparison of the observed magnitudes with theoretical cooling tracks we have estimated the physical properties of the companion star: it has a mass of only 0.19 pm 0.02 Msun, a surface temperature of 12 pm 1 x 10^3 K and a cooling age of 1.0pm0.2 Gyr. Its progenitor was likely a ~ 0.84 M star and the bulk of the mass-transfer activity occurred during the sub-giant branch phase. The companion mass, combined with the pulsar mass function, implies that this system is observed almost edge-on and that the neutron star has a mass of 1.1 pm 0.3 Msun, in agreement with the typical values measured for recycled neutron stars in these compact binary systems. We have also identified a candidate counterpart to the wide and eccentric binary millisecond pulsar J1342+2822D. It is another white dwarf with a He core and a mass of 0.22 pm 0.2 Msun, implying that the system is observed at a high inclination angle and hosts a typical NS with a mass of 1.3 pm 0.3 Msun. At the moment, the large uncertainty on the radio position of this millisecond pulsar prevents us from robustly concluding that the detected star is its optical counterpart.