\(f(x)=-\dfrac{x^2}2+x-\cos^2x\)
\(\implies~f'(x)=-x+1-2\cos x(-\sin x)=-x+\sin2x+1\)
\(\implies~f''(x)=-1+2\cos2x\)
Inflection points always occur at points where the second derivative is equal to zero, but not every such point will be an actual inflection point.
\(-1+2\cos2x=0\iff\dfrac12=\cos2x\)
\(\implies 2x=\pm\dfrac\pi3+2n\pi\)
\(\implies x=\pm\dfrac\pi6+n\pi\)
where \(n\) is an integer. There are infinitely many inflection points for this function.