Generally speaking, rather than including "conditionals" in the title format to work out where in the document the title is used, you either (a) include macros in the format itself which will expand appropriately (e.g. \chaptertitlename
which will be redefined once \appendix
is given) or (b) redefine with a new \titleformat
at the appropriate point in the document.
Since you didn't give a complete compilable MWE I'm guessing somewhat about your settings. But here's a short example. This is basically your code, but (a) instead of "hardcoding" the word "Chapter" in the bit that prints the colored box, I've used \chaptertitlename
and (b) instead of hard-coding a color in the two places you used it, I put a macro which can therefore easily be redefined.
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\newcommand{\chaptercolor}{blue}
\usepackage{tikz}
\titleformat{\chapter}
[display]
{\normalfont\filcenter}
{\tikz[remember picture,overlay]
{\node[fill=\chaptercolor,%<--- Not hardcoded color
font=\sffamily\fontsize{96}{72}\bf\selectfont\color{white},anchor=north east,
minimum width=3cm,
minimum height=3.4cm]
at ([xshift=-1cm,yshift=-1cm]current page.north east)
(numb) {\thechapter};
\node[rotate=90,
anchor=south,
inner sep=4pt,
font=\Huge\sffamily]
at (numb.west) {\chaptertitlename};%<-- Not hardcoded "CHAPTER"
}}
{20pt}
{\Huge\bfseries\color{\chaptercolor}#1}%< Not hardcoded color
[\vskip10pt\Large\bfseries***]
\begin{document}
\frontmatter
\chapter{Preface}
\lipsum
\mainmatter\renewcommand{\chaptercolor}{red}
\chapter{Chapter}
\lipsum
\appendix\renewcommand{\chaptercolor}{green!40!black!60}
\chapter{Appendix Something}
\end{document}

\titleformat
wherever I want a new title format to start... The\titleformat
should act like a switch (similar to a font changing macro like\bfseries
or\itshape
), changing formatting from that point onward; so there's technically no "conditioning" required. A bigger question though: Why do you want to switch formats and not keep things consistent?\titleformat
? For the bigger question, in fact I want to keep the same "global idea" but I want to change things like the "Chapter" word and the color of the node.titlesec
package (the documentation contains some examples) or using theKOMA
classes in order to change the titleformat.\appendix
switch to be used to create appendecies. Shouldn't your third requirement be "chapter in appendix"?