We propose and demonstrate a novel nonoptical technique for regulation of tip-sample distance in a scanning near-field optical microscope (SNOM). The fiber tip for the SNOM is attached to one prong of a quartz tuning fork. The fork is dithered with a gated sinusoidal signal. The vibration of the freely oscillating fiber tip, which manifests as the induced piezoelectric voltage on the fork electrodes, is monitored during the half-period of the gated sinusoid for which the fork is not driven. The time-multiplexing scheme, thus, allows the tuning fork to serve as a dither and a sensor with high Q factor, simultaneously. The gating technique could also potentially allow the SNOM to be used for the investigation of surface relaxation dynamics with high spatial resolution and submillisecond time resolution.