A compact optical terahertz (THz) source was demonstrated based on an efficient high-repetition-rate doubly resonant optical parametric oscillator (OPO) around 2 μm with two type-II phase-matched KTP crystals in the walk-off compensated configuration. The KTP OPO was intracavity pumped by an acousto-optical (AO) Q-switched Nd:YVO4 laser and emitted two tunable wavelengths near degeneracy. The tuning range extended continuously from 2.068 μm to 2.191 μm with a maximum output power of 3.29 W at 24 kHz, corresponding to an optical-optical conversion efficiency (from 808 nm to 2 μm) of 20.69%. The stable pulsed dual-wavelength operation provided an ideal pump source for generating terahertz wave of micro-watt level by the difference frequency generation (DFG) method. A 7.84-mm-long periodically inverted quasi-phase-matched (QPM) GaAs crystal with 6 periods was used to generate a terahertz wave, the maximum voltage of 180 mV at 1.244 THz was acquired by a 4.2-K Si bolometer, corresponding to average output power of 0.6 μW and DFG conversion efficiency of 4.32×10-7. The acceptance bandwidth was found to be larger than 0.35 THz (FWHM). As to the 15-mm-long GaSe crystal used in the type-II collinear DFG, a tunable THz source ranging from 0.503 THz to 3.63 THz with the maximum output voltage of 268 mV at 1.65 THz had been achieved, and the corresponding average output power and DFG conversion efficiency were 0.9 μW and 5.86×10-7 respectively. This provides a potential practical palm-top tunable THz sources for portable applications.