This letter focuses on the secure transmission for an intelligent reflecting surface (IRS)-assisted millimeter-wave (mmWave) and terahertz (THz) system, in which a base station (BS) communicates with its destination via an IRS, in the presence of a passive eavesdropper. To maximize the system secrecy rate, the transmit beamforming at the BS and the reflecting matrix at the IRS are jointly optimized with transmit power and discrete phase-shift constraints. It is first proved that the beamforming design is independent of the phase shift design under the rank-one channel assumption. The formulated non-convex problem is then converted into two subproblems, which are solved alternatively. Specifically, the closed-form solution of transmit beamforming at the BS is derived, and the semidefinite programming (SDP)-based method and element-wise block coordinate descent (BCD)-based method are proposed to design the reflecting matrix. The complexity of our proposed methods is analyzed theoretically. Simulation results reveal that the proposed IRS-assisted secure strategy can significantly boost the secrecy rate performance, regardless of eavesdropper's locations (near or blocking the confidential beam).