Let $a_n$ be the number of length $n$ sequences of the English Alphabet that don't contain the word $DOG$. Now, adding any letter except $D$ to the beginning of an $n-1$ length sequence that doesn't containg $DOG$, will not contain the word $DOG$. The tricky case is when you add a $D$.
So how many $n-1$ length sequences are there that don't contain $DOG$, and don't start with $OG$? Let's say $b$ is the number of $n-1$ length sequences that do start with $OG$ and don't contain $DOG$. Then our answer is $a_{n-1}-b$.
But what is $b$? $b$ is precisely $a_{n-3}$ because the first two letters are already determined, and we just need to know how many $n-3$ length sequences don't contain $DOG$, to fill up the remaining letters.
In total, we have that $$a_n=25a_{n-1} + (a_{n-1}-a_{n-3})=26a_{n-1}-a_{n-3}$$
and
$$a_0=1,$$ $$a_1=26,$$ $$a_2=26^2.$$ The base values are easy because none of the words are long enough to contain $DOG.$
A small thing: when you say "So how many $n-1$ length sequences are there that don't contain $DOG$ and don't start with $OG$?"
Wouldn't another way to think of it be: $25 \times 26 \times a_{n-3}$?
Since consider the string of $n-1$ letters. There's $25$ choices for first letter not being $O$, and second letter being anything ($26$ choices), then there are $n-3$ letters remaining, where we don't want $DOG$ to appear, so $a_{n-3}$. – Natash1 Oct 15 '17 at 04:36