The titling
package redefines \maketitle
. Therefore it breaks the usage of KOMA-Script command \titlehead
.
You can use package scrlayer
or scrlayer-scrpage
to add the title head:
\usepackage{scrlayer}% or scrlayer-scrpage which loads scrlayer
\DeclareNewLayer[%
headsep,
foreground,
contents={%
\begin{minipage}[t]{\textwidth}%
\usekomafont{titlehead}{\csname @titlehead\endcsname\par}%
\end{minipage}\par}
]{titlehead}
\DeclarePageStyleByLayers{titlepage}{titlehead}
\AddToHook{cmd/maketitle/after}{\thispagestyle{titlepage}}
Important remark: Do not use package titlsec
together with a KOMA-Script class. It breaks KOMA-Script features. Therefore you will get a bunch of warnings and maybe errors. Additionally this package defines an own \thetitle
. So it is the reason for your second issue.
Here is a suggestion replacing your titlesec
settings by KOMA-Script commands:
\documentclass[a4paper,12pt,bibliography=totoc,
numbers=noenddot,% <- added
sfdefaults=false% <- added (replaces \setkomafont{disposition}{\bfseries}), needs version 3.39 or newer
]{scrartcl}
%----------------------
\usepackage{titling}
\pretitle{\huge \centering \bfseries }
\posttitle{\par \vspace{\baselineskip}} %
\preauthor{\centering \normalsize}
\postauthor{\par}
\setkomafont{section}{\fontsize{14}{12}\selectfont}
\setkomafont{subsection}{\fontsize{12}{12}\selectfont}
\setkomafont{subsubsection}{\normalfont\itshape\fontsize{14}{12}\selectfont}
\renewcommand{\sectionformat}{\thesection\autodot\hspace{1em}}
\renewcommand{\subsectionformat}{\thesubsection\autodot\hspace{1em}}
\renewcommand{\subsubsectionformat}{\thesubsubsection\autodot\hspace{1em}}
\usepackage{scrlayer}% or scrlayer-scrpage which loads scrlayer
\DeclareNewLayer[%
headsep,
foreground,
contents={%
\begin{minipage}[t]{\textwidth}%
\usekomafont{titlehead}{\csname @titlehead\endcsname\par}%
\end{minipage}\par}
]{titlehead}
\DeclarePageStyleByLayers{titlepage}{titlehead}
\AddToHook{cmd/maketitle/after}{\thispagestyle{titlepage}}
%----------------------------------
\usepackage[affil-it]{authblk}
\usepackage{blindtext}
\usepackage{newtxtext} % text in Times font
\usepackage{newtxmath} % math in Times font
%\usepackage{fontspec}
%\setmainfont{Times New Roman}
\titlehead{THIS NEEDS TO BE DISPLAYED \hfill}
\title{Main Title}
\subtitle{Sub Title}
\author[1,2,*]{First Author}
\author[1,2]{Second Author}
\author[1,3]{Third Author}
\author[2,4]{Supervisor Author}
\affil[1]{University}
\affil[2]{College}
\affil[3]{Institute}
\affil[4]{School \break}
\affil[*]{Corresponding author: [email protected] \newline Contributing authors: [email protected], [email protected], [email protected]}
\date{\today}
\begin{document}
\maketitle
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
Reference to the title, which is: \thetitle. % dependent on the titling-package
\end{document}

Update:
If the title page should use the same footer like other pages, load package scrlayer-scrpage
and add the footer layers to the new layer page style:
\usepackage{scrlayer-scrpage}% sets page style scrheadings automatically
\DeclareNewLayer[%
headsep,
foreground,
contents={%
\begin{minipage}[t]{\textwidth}%
\usekomafont{titlehead}{\csname @titlehead\endcsname\par}%
\end{minipage}\par}
]{titlehead}
\DeclarePageStyleByLayers{titlepage}{titlehead}
\ForEachLayerOfPageStyle{scrheadings}{%
\Ifstrstart{#1}{scrheadings.foot}{\AddLayersToPageStyle{titlepage}{#1}}%
}
\AddToHook{cmd/maketitle/after}{\thispagestyle{titlepage}}
Example:
\documentclass[a4paper,12pt,bibliography=totoc,
numbers=noenddot,% <- added
sfdefaults=false% <- added (replaces \setkomafont{disposition}{\bfseries}), needs version 3.39 or newer
]{scrartcl}
%----------------------
\usepackage{titling}
\pretitle{\huge \centering \bfseries }
\posttitle{\par \vspace{\baselineskip}} %
\preauthor{\centering \normalsize}
\postauthor{\par}
\setkomafont{section}{\fontsize{14}{12}\selectfont}
\setkomafont{subsection}{\fontsize{12}{12}\selectfont}
\setkomafont{subsubsection}{\normalfont\itshape\fontsize{14}{12}\selectfont}
\renewcommand{\sectionformat}{\thesection\autodot\hspace{1em}}
\renewcommand{\subsectionformat}{\thesubsection\autodot\hspace{1em}}
\renewcommand{\subsubsectionformat}{\thesubsubsection\autodot\hspace{1em}}
\usepackage{scrlayer-scrpage}% sets page style scrheadings automatically
\DeclareNewLayer[%
headsep,
foreground,
contents={%
\begin{minipage}[t]{\textwidth}%
\usekomafont{titlehead}{\csname @titlehead\endcsname\par}%
\end{minipage}\par}
]{titlehead}
\DeclarePageStyleByLayers{titlepage}{titlehead}
\ForEachLayerOfPageStyle{scrheadings}{%
\Ifstrstart{#1}{scrheadings.foot}{\AddLayersToPageStyle{titlepage}{#1}}%
}
\AddToHook{cmd/maketitle/after}{\thispagestyle{titlepage}}
%----------------------------------
\usepackage[affil-it]{authblk}
\usepackage{blindtext}
\usepackage{newtxtext} % text in Times font
\usepackage{newtxmath} % math in Times font
%\usepackage{fontspec}
%\setmainfont{Times New Roman}
\titlehead{THIS NEEDS TO BE DISPLAYED \hfill}
\title{Main Title}
\subtitle{Sub Title}
\author[1,2,*]{First Author}
\author[1,2]{Second Author}
\author[1,3]{Third Author}
\author[2,4]{Supervisor Author}
\affil[1]{University}
\affil[2]{College}
\affil[3]{Institute}
\affil[4]{School \break}
\affil[*]{Corresponding author: [email protected] \newline Contributing authors: [email protected], [email protected], [email protected]}
\date{\today}
\begin{document}
\maketitle
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
Reference to the title, which is: \thetitle. % dependent on the titling-package
\end{document}
