The question of whether any given equations of motion come from the principle of least action for any Lagrangian, and, if so, if that Lagrangian is unique up to adding total derivatives, is called the inverse problem of the calculus of variations. There is extensive literature on this. The following answer is mostly based on "The inverse problem in the calculus of variations and the geometry of the tangent bundle" by Morandi, Ferrario, lo Vecchio, Marmo and Rubano (Morandi et al. for short in the following).
Morandi et al. deal with the problem using differential geometry on arbitrary configuration spaces $Q$; this answer will work only on $Q=\mathbb{R}^n$ and eschew most of the formal machinery; read the paper if you are interested in the formal proofs of the assertions herein.
The Euler-Lagrange equations of motion for a time-independent Lagrangian $L(q,\dot{q})$ that is regular as $\mathrm{det}\dfrac{\partial^2 L}{\partial \dot{q}\partial\dot{q}} \neq 0$ can be cast into the general form
$$ \frac{\mathrm{d}q}{\mathrm{d}t} = \dot{q} \quad \land \quad \frac{\mathrm{d}\dot{q}}{\mathrm{d}t} = F(q,\dot{q}) \tag{1}\label{1}$$
for $F(q,\dot{q})$ the generalized forces. Non-regular Lagrangians correspond in general to theories with gauge symmetries, which will be outside of the scope of this answer, but see this answer of mine for more on gauge symmetries for non-regular Lagrangians.
Admissible Lagrangians and the difficulty of uniqueness
There is a straightforward and obvious definition of a Lagrangian that "does what we want" - a Lagrangian that is admissible for the equations $\eqref{1}$ is one where the solutions to these equations are also solutions to the E-L equations of the Lagrangian. Unfortunately, this definition is too weak in a certain sense: The Lagrangian $L=0$ has as its E-L equations $0=0$, i.e. all trajectories are solutions, and so it is admissible for all equations of motion. More generally, this then, of course, holds also for the total derivatives $L=\dot{h}$ for some $h(q(t),\dot{q}(t))$.
In these terms, the question becomes: Is there an admissible Lagrangian for $\eqref{1}$ that is not a total derivative, and if so, can there be two different admissible Lagrangians such that their difference is not a total derivative? Note that since $\lambda L$ and $L$ have the same E-L equations for any $\lambda\in\mathbb{R}\setminus\{0\}$, the space of admissible Lagrangians is a vector space, and when we only want to talk "up to total derivative", we're quotienting out the subspace of Lagrangians of the form $L = \dfrac{\mathrm{d}h}{\mathrm{d}t}$.
"The" admissible Lagrangian is unique when this space is 1-dimensional.
Existence of admissible Lagrangians and symmetries
Not all equations of the form $\eqref{1}$ actually admit a Lagrangian description. For instance, the generalized forces
\begin{align}
F^x & = x+y \\
F^y & = xy
\end{align}
in two dimensions have no admissible Lagrangian except the trivial $L=0$.
If a non-trivial admissible Lagrangian exists, it is not necessarily unique. An example of a system of equations with two distinct admissible Lagrangians is the two-dimensional harmonic oscillator, where the Lagrangians
\begin{align}
L_1 & = \dot{q}^2 - q^2 \\
L_2 & = \dot{q}^x\dot{q}^y - q^x q^y \\
\end{align}
both lead to the same set of equations of motion.
The existence of inequivalent admissible Lagrangians is related to the existence of symmetries of the equations of motion that are not Noetherian symmetries. Morandi et al. prove the following statement (section 3.7, particularly proposition 3.24):
If $X$ is the generator of a continuous symmetry of the equations of motion $\eqref{1}$ and $L$ is an admissible Lagrangian, then the infinitesimal change $\delta_X L$ is also an admissible Lagrangian. Conversely, if $\delta_X L$ is an admissible Lagrangian for the generator of a continuous transformation $X$, then the transformations generated by $X$ are symmetries of the equations of motion.
There are three cases to distinguish:
If we start from the trivial Lagrangian $L=0$, the content of this statement is empty, as $\delta_X L = 0$ for all $X$.
Starting from a non-trivial Lagrangian $L$, $\delta_X L$ is trivial, i.e. $\delta_X L = \dfrac{\mathrm{d}h}{\mathrm{d}t}$. In that case, $X$ is a Noetherian (quasi-)symmetry, and there is a conserved quantity associated with $X$ via Noether's theorem.
Starting from a non-trivial Lagrangian $L$, $\delta_X L$ is non-trivial. If it is not a multiple of $L$, it is an inequivalent admissible Lagrangian. $X$ is not Noetherian, and there is no conserved quantity associated with it.
Returning to the original question
Now we can answer the question the OP actually asked: Given a Lagrangian $L$, are total derivatives $L' = \dfrac{\mathrm{d}h}{\mathrm{d}t}$ the only thing that can be added to it such that $L+L'$ has the same equations of motion?
This is the case if and only if all symmetries of the equations of motion are also symmetries of the Lagrangian $L$, i.e. Noetherian symmetries. If, instead, the E-L equations of $L$ have additional symmetries that are not symmetries of $L$ itself, then there exist inequivalent admissible Lagrangians and they can be produced by those symmetries acting on $L$.