Setup
Let
$$ dZ_t=X_t\,dt+Y_t\,dB_t, $$and let $f\in C^2$.
Formula
Then
$$ df(Z_t)=f'(Z_t)\,dZ_t+\frac12 f''(Z_t)\,d\langle Z\rangle_t. $$Substituting
$$ d\langle Z\rangle_t=Y_t^2\,dt $$gives
$$ df(Z_t)
\left(f’(Z_t)X_t+\frac12 f’’(Z_t)Y_t^2\right)dt + f’(Z_t)Y_t,dB_t. $$
Martingale test
The $dB_t$ term is the martingale part. If the $dt$ coefficient is zero, then $f(Z_t)$ is a martingale.