Indeed, when $f$ is a polynomial you will get a differential equation. Define
$$g(x)=\sum_{n=0}^\infty a_n x^n.$$
Then
$$h(x):=\frac{g(x)-a_0}{x}-g(x)=\sum_{n=0}^\infty (a_{n+1}-a_n)x^n=\sum_{n=0}^\infty a_{n+2}f(n) x^n. \tag{1}$$
Now the falling factorials form a $\Bbb Q$-basis for the vector space of rational-coefficient polynomials, thus we can write $f(n)=\sum_k c_k (n)_k$ and obtain
$$h(x) = \sum_k c_k\sum_{n=0}^\infty a_{n+2} (n)_k x^n = \left(\sum_k c_k x^k \frac{d^k}{dx^k}\right)\underbrace{\sum_{n=0}^\infty a_{n+2}x^n}_{\ell(x)}. \tag{2}$$
Note that
$$\ell(x)=\frac{g(x)-a_0-a_1x}{x^2}.$$
Combining $(1)$ and $(2)$ gives the desired differential equation. Similar algebra works when $f$ is a combination of powers and exponentials as well. I'm not sure if there's a general solution to the problem, though...