This problem is better approached by looking first at the number $g(n,k)$ of $n$ coin toss outcomes that have less than $k$ consecutive heads. Call such outcome 'valid'. Each valid outcome will start with one of T, HT, HHT,... up to H...HT with $k-1$ H's at the beginning, and the number of valid outcomes in each case will be $g(n-1,k), g(n-2,k), \dots , g(n-k,k)$. This leads to the recurrence relation: $g(n,k) = g(n-1,k) + g(n-2,k) + \cdots + g(n-k,k)$. The initial values for that recurrence are $g(1,k) = 2, g(2,k) = 4,\dots, g(k-1,k) = 2^{k-1}, g(k,k) = 2^k - 1$. Solve the recurrence, and then the function you are looking for is $f(n,k) = 2^n - g(n,k)$. The particular case you mention with $n=5$, $k=2$ yields the recurrence $g(n,2) = g(n-1,2) + g(n-2,2)$, $g(1,2) = 2$, $g(2,2) =3$, so $g(n,k)$ is the $(n+2)$th Fibonacci number, hence $g(5,2) = F_7 = 13$, and $f(5,2) - 2^5 - 13 = 19$ (besides the 17 outcomes you wrote there are two more, namely HTTHH and THTHH).