A solution to this was proposed to a question I asked, (albeit I was worried also worried about if the page numbers became very large too) and improved in this answer, but I don't think it's fair to say your question is a duplicate, so I'll repeat/copy some of their answers here:
Set rightindent in the TOCStyleEntries from the tocbasic package:
\documentclass{extarticle}
\usepackage{lipsum}
\usepackage[nottoc]{tocbibind}
\usepackage{tocbasic}
\DeclareTOCStyleEntries[
rightindent=10em,% <-- Adjust as you wish
pagenumberbox=\pagenumberbox
]{tocline}{section,subsection,subsubsection,paragraph,subparagraph,figure,table}
\newcommand*\pagenumberbox[1]{\mbox{\hspace{0.5em}#1}}
\begin{document}
\tableofcontents
\addtocontents{toc}{\sloppy}
\pagenumbering{arabic}
\section{Something}
\subsection{Something else}
\subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this}
\end{document}
