Optical frequency combs in the terahertz frequency range are long-awaited frequency standards for spectroscopy of molecules and high-speed communications. However, a terahertz frequency comb based on a compact, efficient and room-temperature-operating device remains unavailable especially in the frequency range of 0.1 to 3 THz. In this paper, we show that the resonant-tunneling-diode oscillator can be passively mode-locked by optical feedback and generate a terahertz frequency comb. The standard deviation of the spacing between the comb lines, i.e., the repetition frequency, is reduced to less than 420 mHz by applying external bias modulation. A simulation model successfully reproduces the mode-locking behavior by including the nonlinear capacitance of RTD and multiple optical feedback. Since the mode-locked RTD oscillator is a simple semiconductor device that operates at room temperature and covers the frequency range of 0.1 to 3 THz, it can be used as a frequency standard for future terahertz sensing and communications.