Let me start with a general discussion, in arbitrary dimensions. Suppose we have a manifold $M$ (possibly with boundary) and a vector field $V$. (I will assume it points inwards at the boundary for simplicity.) I also take the sign convention that a Lyapunov function has $df(V) \le 0$ with equality only at zeros of $V$.
The existence of a Lyapunov function is a strong topological condition on $V$, but in some sense, if it exists, it is unique (from a topologist's point of view). Indeed, suppose I have two Lyapunov functions $f_1$ and $f_2$, then I can take a convex combination to give a Lyapunov function (actually, I can take a positive cone). This means the space of Lyapunov functions is contractible and thus "unique" as far as a topologist is concerned.
Now, let's see some constraints that having a Lyapunov function imposes on the vector field. As the question correctly points out, you can't have any periodic orbits since the values of the Lyapunov function have to decrease along flow lines of the vector field. Let's now assume that $V$ has non-degenerate, isolated zeros, again for simplicity. Having a Lyapunov function now also rules out having zeros $p_1, \dots, p_N$ with a trajectory going from $p_1$ to $p_2$, $p_2$ to $p_3$, etc. and $p_N$ to $p_1$ again. (I will refer to this as a heteroclinic cycle, though the case $N=1$ is a homoclinic.) In higher dimensions, there are many more complicated configurations that can also prevent the existence of a Lyapunov function.
Let's consider the case of a surface. I can easily prove a special case of what you want, but will have to think a little bit about the general statement. The easy claim is that if $V$ has non-degenerate zeros, none of whose linearizations have purely imaginary eigenvalues, and if $V$ doesn't have periodic orbits and doesn't have heteroclinic cycles, then there exists a Lyapunov function.
The claim is more-or-less constructive (I don't believe this will give you a usable algorithm). The heart of the discussion is the Poincaré-Bendixson theorem. Combining with our lack of periodic orbits, this tells us that for any forward-time flow invariant set $S$, the $\omega$-limit set will consist of a collection of critical points and their connecting trajectories. By our second hypothesis, our connecting trajectories will not form any loops. We therefore have a tree in our surface whose vertices are zeros of $V$ and whose edges are flow lines of $V$. By the Poincaré-Bendixson theorem, this is the $\omega$-limit set of the surface. We can construct a local Lyapunov function in the neighbourhood of the tree by using the linearizations of $V$ at the zeros (so the function will be quadratic in small neighbourhoods of the zeros), and then patch these together (this needs a little bit of care).
Once we have the Lyapunov function in the neighbourhood of this tree, we can extend it to the surface by defining $f(x ) = t+ f( \phi_t(x) )$ where $t$ is the first time such that $\phi_t(x)$ is in the neighbourhood. This isn't quite smooth, but can be smoothed easily.
More generally, the existence of a Lyapunov function for a vector field is telling you that the vector field is "gradient-like" (or a "pseudogradient vector field"). Such a vector field allows you to reconstruct the homology of the manifold, so they are objects of interest.