We can simply add or subtract, to get a correct answer. So for the sum, we have $s(x)=(-5+2\cos (x))+(\cos(x-\pi/4)-2)=2\cos(x)+\cos(x-\pi/4)-7,$ and for the difference we have $d(x)=(-5+2\cos (x))-(\cos(x-\pi/4)-2)=2\cos(x)-\cos(x-\pi/4)-3.$
But I imagine you are expected to do more. You may be expected to proceed as follows:
$1$. Use the addition/subtraction law for cosines to express $\cos(x-\pi/4)$ as $(\cos x)(\cos(\pi/4))+(\sin x)(\sin(\pi/4))$. So we get $\cos(x-\pi/4)=\frac{1}{\sqrt{2}}\cos x+\frac{1}{\sqrt{2}}\sin x.$
$2.$ Now add $f(x)$ and the modified version of $g(x)$. (Or, for the other part of the question, subtract.) So for the sum we would have $f(x)+g(x)=\left(2+\frac{1}{\sqrt{2}}\right)\cos x +\frac{1}{\sqrt{2}}\sin x -7.$
$3.$ In certain Physics-oriented courses, you may be expected to do further processing. After doing $(2.)$, we have something of the shape $k+a\sin x+b\cos x$. You may be expected to express $a\sin x+b\cos x$ as a single trigonometric function. The idea is that $a\sin x+b\cos x=\sqrt{a^2+b^2}\left(\frac{a}{\sqrt{a^2+b^2}}\sin x+ \frac{b}{\sqrt{a^2+b^2}}\cos x\right).$
Now let $\theta$ be any angle whose cosine is $\frac{a}{\sqrt{a^2+b^2}}$ and whose sine is $\frac{b}{\sqrt{a^2+b^2}}$. Then $a\sin x+b\cos x=\sqrt{a^2+b^2}\sin(x+\theta).$