I restyled the \section and \subsection a little bit, to better suite my needs when writing assignments. Using titlesec, I moved the (sub)section number to the right of the (sub)section title. In my preamble:

\usepackage[compact,explicit]{titlesec}

\def\thesection{\Roman{section}}
\titleformat{\section}[hang]{\Large\bfseries}{}{0pt}{#1 \thesection}
\def\thesubsection{\roman{subsection}:}
\titleformat{\subsection}[runin]{\large\itshape}{}{0pt}{#1 \thesubsection:}


In my documents, I usually use \section{Part} and \subsection{Question}, depending on the assignment. The advantage of course is, that I don't have to worry about Question numbering.

However, the problem is that in the table of contents the (sub)section number is of course still displayed on the left, while I want both on the right as well.

I looked at the tocloft package, but I can't figure out this particular case.

-
A tip: You can use backticks  to mark your inline code as I did in my edit. –  egreg Nov 20 '12 at 23:28
I will keep it in mind for next time, thanks. –  altabq Nov 21 '12 at 11:56

Here's a possible solution; the idea is to set tocdepth to 0 inside the redefinition for the section headings so they won't be automatically included in the ToC; then the titles are manually included using \addcontentsline with the desired formatting (title, number, page number); finally, the etoolbox package is used to restore the tocdepth counter to its default value:

\documentclass{article}
\usepackage[compact,explicit]{titlesec}
\usepackage{etoolbox}

\def\thesection{\Roman{section}}
\def\thesubsection{\roman{subsection}}

\titleformat{\section}[hang]
{\Large\bfseries}{}{0pt}{#1 \thesection%
\titleformat{name=\section,numberless}[hang]
{\Large\bfseries}{}{0pt}{#1}
\titleformat{\subsection}[runin]
{\large\itshape}{}{0pt}{#1 \thesubsection:}
\titleformat{name=\subsection,numberless}[runin]
{\large\itshape}{}{0pt}{#1:}

\begin{document}

\tableofcontents
\section{Test Section One}
\subsection{Test}
\section{Test Section Two}

\end{document}


Not relevant to the problem mentioned, but I provided also definitions to be applied to the unnumbered sections and subsections (produced with \section* and \subsection*) to prevent numbering them.

Another option, is to use a new auxiliary file (with extension .moc, for example) and redefine \tableofcontents so that \@starttoc uses moc instead of toc; this simple trick simplifies the solution (no patching required) and it is more suitable in case the new formatting has to be applied to more sectional units (as was requested in a comment to the original answer); here's a complete example illustrating this approach:

\documentclass{article}
\usepackage[compact,explicit]{titlesec}

\def\thesection{\Roman{section}}
\def\thesubsection{\roman{subsection}}

\titleformat{\section}[hang]
{\Large\bfseries}{}{0pt}{#1 \thesection%
}
\titleformat{name=\section,numberless}[hang]
{\Large\bfseries}{}{0pt}{#1}
\titleformat{\subsection}[runin]
{\large\itshape}{}{0pt}{#1 \thesubsection:%
\titleformat{name=\subsection,numberless}[runin]
{\large\itshape}{}{0pt}{#1:}

\makeatletter
\renewcommand\tableofcontents{%
\section*{\contentsname
\@mkboth{%
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
\@starttoc{moc}%
}
\makeatother
\begin{document}

\tableofcontents
\section{Test Section One}
\subsection{Test Subsection A}
\subsection{Another Test Subsection A}
\section{Test Section Two}
\subsection{Test Subsection B}
\subsection{Another Test Subsection B}

\end{document}
`

-
Thanks a lot for this. I tried to replicated the answer to move subsection titles in the tableofcontents to the right as well, but couldn't get it to work. could you extent your example to fit that in as well please? –  altabq Nov 21 '12 at 10:28
@altabq of course. Please see my updated answer; the last code contains a more general approach; the nice thing is that this more general approach is simpler than the particular case I initially addressed. –  Gonzalo Medina Nov 21 '12 at 15:59
thank you very much! I added your code to my preamble and it works flawlessly! –  altabq Nov 22 '12 at 23:17