The method called Lagrange Multipliers is used to find critical points of $f(x_1,x_2,\ldots,x_n)$, when $f$ is constrained to the level set $S = \{ x\in \mathbb{R}^n \, | \, g(x_1,x_2,\ldots,x_n)=0 \}$. These critical points may be used to locate local minima and maxima.
When $S$ is a compact set, we know that a global max and min of $f$ exist on $S$.
Do we also have to check what happens on the boundary of $S$, in case a boundary exists ?
Yes. For example, $f(x,y) = x^2+y^2$ and $g(x,y)=|x|+|y|-1$. Then $S$ is a series of smooth lines joined at sharp corners. The maxima are attained at these corners. You can make a more convoluted $g$ to make these corners just ends.