This work presents a penalty approach to a nonlinear optimization problem with linear box constraints arising from the discretization of an infinite-dimensional differential obstacle problem with bound constraints on derivatives. In this approach, we first propose a penalty equation approximating the mixed nonlinear complementarity problem representing the Karush-Kuhn-Tucker conditions of the optimization problem. We then show that the solution to the penalty equation converges to that of the complementarity problem with an exponential convergence rate depending on the parameters used in the equation. Numerical experiments, carried out on a non-trivial test problem to verify the theoretical finding, show that the computed rates of convergence match the theoretical ones well