The inverse problem of the calculus of variations (IPCV) is solved for a second-order ordinary differential equation with the use of a local bilinear form. We apply methods of analytical dynamics, nonlinear functional analysis, and modern methods for solving the IPCV. In the paper, we obtain necessary and sufficient conditions for a given operator to be potential relative to a local bilinear form, construct the corresponding functional, i.e., found a solution to the IPCV, and define the structure of the considered equation with the potential operator. As a consequence, similar results are obtained when using a nonlocal bilinear form. Theoretical results are illustrated with some examples. © 2021, Krasovskii Institute of Mathematics and Mechanics. All rights reserved.