Using the scrreprt document class, I get a table of contents that uses non serif fonts for everything, except for sections:

Now I've been asked to change this to non serif for the sections as well. tex --version says TeX 3.14159265 (TeX Live 2015/Debian) on my machine, but from what I've seen on my search for a solution, this actually appears to be the intended default behavior, so it should be reproducible on other machines using this MWE:

\documentclass[toc=chapterentrywithdots]{scrreprt}
\begin{document}
\tableofcontents
\chapter{Testing Text Chapter 1}
Testing Text Chapter 1
\section{Testing Text Section 1}
Testing Text Section 1
\section{Testing Text Section 2}
Testing Text Section 2
\end{document}


The more common question regarding this topic appears to be how to change the font to non serif only or serif only for the whole document, but this is not what I want to achieve. Currently, I have non serif headers and serif text throughout my complete document, and it should stay this way. Only the sections in the table of contents should be non serif, preferably using a clean solution instead of a dirty hack.

With an older KOMA-Script version - like that one in TL 2015 - you can use

\AfterTOCHead[toc]{\sffamily\renewcommand\familydefault{\sfdefault}}


This works with uptodate KOMA-Script versions, too. But note, it changes also the font family for ToC entries of subsections, subsubsections etc.

Example:

\documentclass[toc=chapterentrywithdots]{scrreprt}

\AfterTOCHead[toc]% without the optional argument, it also affects LoF and LoT
{\sffamily\renewcommand\familydefault{\sfdefault}}

\begin{document}
\tableofcontents
\chapter{Testing Text Chapter 1}
Testing Text Chapter 1 \KOMAScriptVersion
\section{Testing Text Section 1}
Testing Text Section 1
\section{Testing Text Section 2}
Testing Text Section 2
\end{document}


Result:

Only with uptodate KOMA-Script versions (not with TL 2015!) you can use

\RedeclareSectionCommand[%
tocentryformat=\sffamily,%
tocpagenumberformat=\sffamily
]{section}


or if there are subsections too

\RedeclareSectionCommands[% note the "s" at the end
tocentryformat=\sffamily,%
tocpagenumberformat=\sffamily%
]{section,subsection}


Or you could use

\DeclareTOCStyleEntry[% note the "s" at the end
entryformat=\sffamily,%
pagenumberformat=\sffamily%
]{default}{section}


This can also be used for figure and table entries in LOF and LOT, respectively:

\DeclareTOCStyleEntry[% note the "s" at the end
entryformat=\sffamily,%
pagenumberformat=\sffamily%
]{default}{figure}


I don't know if this is the easiest way, but here this works:

\documentclass[toc=chapterentrywithdots]{scrreprt}
\begin{document}

\RedeclareSectionCommand[%
tocentryformat=\sffamily%
]{section}

\tableofcontents
\chapter{Testing Text Chapter 1}
Testing Text Chapter 1
\section{Testing Text Section 1}
Testing Text Section 1
\section{Testing Text Section 2}
Testing Text Section 2
\end{document}
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9860220551490784, "perplexity": 5349.171844429991}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-51/segments/1575540523790.58/warc/CC-MAIN-20191209201914-20191209225914-00033.warc.gz"}