I think this is fine. Indeed, $S$ as a function of $B$ is of negligible size. This can also be checked as follows. Using Mellin transform and absolute convergence of the Dirichlet series of $\lambda$ one can write
$$S=\sum_{n\ge 1}\lambda(n)\int_{\Re(s)=\sigma}\left(\frac{n}{B}\right)^{-s}\tilde{f}(s)ds=\int_{\Re(s)=\sigma} L(s,\phi)B^{s}\tilde{f}(s)ds,$$
for $\sigma>0$ sufficiently large. 
Here $\tilde{f}(s)$ is the Mellin transform of $f$, which is entire and decays rapidly in fixed vertical strips. $L(s,\phi)$ is the $L$-function of the cusp form attached to $\lambda$, which is entire. This allows us to shift the contour of the above integral to $\sigma=-N$ for any $N>0$. The shifted integral can be bounded by
$$\ll_N B^{-N} \int_{Re(s)=-N}|\tilde{f}(s)L(s,\phi)| |ds| \ll_N B^{-N}$$
where we bound $L(\sigma+it,\phi)\ll_\sigma (1+|t|)^{O_\sigma(1)}$.