WASHINGTON—A Texas Republican congressman facing allegations of sexual harassment said he won’t run for re-election and will leave Congress at the end of his term.

Rep. Blake Farenthold used a taxpayer fund to settle a sexual-harassment claim by an employee three years ago, court documents and congressional data show. Lauren Greene, the lawmaker’s former communications director, sued Mr. Farenthold’s office in December 2014 alleging wrongful termination.

Mr....