Your problem is the classical inverse problem formulated by Helmholtz in 1887. This problem is, as far as I know, completely solved by Mayer and Hirsch in 1897. If you want a complete and modern study of this problem, you can read the book of Olver "Applications of Lie groups to differential equations". In this book, the multidimensional case (PDE) with general order is studied.
In my thesis (above cited by Sylvain L.), I gave an explicit formulation of the Helmholtz condition in the unidimensional case (ODE) with second order. In this particular (and simpler) case, the Helmholtz condition can be written in a very simple way. You will find it in Equation (IV.2.12) p.67. This condition is sufficient and necessary in order to ensure that a second order differential operator $O$ is a (second-order) Euler-Lagrange operator.
Now, if you consider a second order differential operator $O$ that satisfies the Helmholtz condition, and if you want to find a Lagrangian $L$ such that $EL[L]=O$ (where $EL$ is the Euler-Lagrange operator), then you can follow the step of the proof of Theorem IV-2 p.67. This proof gives an explicit way to construct such a Lagrangian $L$.
Remark: Note that $L$ is not unique since there exist some "null Lagrangian", see Section IV-2-3 p.69.