The $K$ in your formula is the largest possible absolute value of the second derivative of your function. So let $f(x)=x\cos x$. We calculate the second derivative of $f(x)$.
We have $f'(x)=-x\sin x+\cos x$. Differentiate again. We get
$$f''(x)=-x\cos x-\sin x-\sin x=-(2\sin x+x\cos x).$$
Now in principle, to find the best value of $K$, we should find the maximum of the absolute value of the second derivative. But we won't do that, it is too much trouble, and not really worth it.
So how big can the absolute value of the second derivative be? Let's be very pessimistic. The number $x$ could be as large as $\pi$. The absolute value of $\cos x$ and $\sin x$ is never bigger than $1$, so for sure the absolute value of the second derivative is $\le 2+\pi$. Thus, if we use $K=2+\pi$, we can be sure that we are taking a pessimistically large value for $K$.
Note that at $\pi$, the cosine is $-1$ and the sine is $0$, so the absolute value of the second derivative can be as large as $\pi$.
We can be less pessimistic. In the interval from $0$ to $\pi/2$, our second derivative is less than $2+\pi/2$. We can do better than that by looking at the second derivative in more detail, say between $0$ and $\pi/4$, and between $\pi/4$ and $\pi/2$.
In the interval from $\pi/2$ to $\pi$, the cosine is negative, while the sine is positive. The sine is definitely $\le 2$. The $x\cos x$ term is negative, so in the interval $[\pi/2,\pi]$, the absolute value of the derivative is less than or equal to the larger of $2$ and $\pi$, which is $\pi$.
So we have reduced our upper bound on the absolute value of the second derivative to $2+\pi/2$, say about $3.6$. We could do a bit better by graphing the second derivative on a graphing calculator, and eyeballing the largest absolute value.
It's not worth it. Use $K\le 3.6$ (or even $2+\pi$). Then we know that the error has absolute value which is less than or equal to
$$\frac{3.6\pi^3}{12n^2}.$$
We want to make sure that the above quantity is $\le 0.0001$. Equivalently, we want
$$n^2\ge \frac{3.6\pi^3}{(12)(0.0001}.$$
Finally, calculate. I get something like $n=305$.
Remark: There are many reasons not to work too hard to find the largest possible absolute value of the second derivative. If we are using numerical integration on $f$, it is probably because $f$ is at least a little unpleasant. Usually then, $f''$ will be more unpleasant still, and finding the maximum of its absolute value could be very difficult.
In addition, using the maximum of $|f''(x)|$ usually gives a needlessly pessimistic error estimate. I am certain that for the Trapezoidal Rule with your function, in reality we only need an $n$ much smaller than $305$ to get error $\le 0.0001$. The error estimate for the Trapezoidal Rule is close to the truth only for some really weird functions. For "nice" functions, the error bound you were given is unduly pessimistic.
The usual procedure is to calculate say $T_2$, $T_4$, $T_8$, and so on until successive answers change by less than one's error tolerance. This is theoretically not good enough, but works well in practice, particularly if you cross your fingers.
Best Answer
You require $K$ such that \begin{equation} |f''(x)| \leq K \end{equation} for all $x \in [0,10]$. Fortunately your function $f''$ is positive and strictly decreasing, so \begin{equation} K = f''(0) = 4 \end{equation} is a good choice. Then you can simple determine the smallest positive integer $n$ such that \begin{equation} \frac{K(b-a)^3}{n^2} \leq \tau \end{equation} where $\tau = 10^{-4}$ is your maximum acceptable error.