How can I check for the accuracy of numerical result to optimization problem? How can I check for the accuracy of numerical result to optimization problem?

Or when is this possible?

Intuitively it could be possible at least to some extent, when one knows how to find analytic solutions or analytic approximations.

However, what if one just starts with some numerical solution, but the problem is e.g. non-linear. Then is there anyway to know, whether one can trust the optimization routine to have found the correct answer and not some other?
If you have an objective function in low dimensions (e.g., one or two scalar variables) then the simplest way of checking your optimising value is to plot the function and look at the optimising value.  You should be able to see if the optimising value you have calculated is actually at a minimising/maximising point.  If your objective function is in higher dimensions then this gets trickier, but you can always hold some argument values constant (at the optimising point) and check the others with plots.
If you have an objective function in low dimensions (e.g., one or two scalar variables) then the simplest way of checking your optimising value is to plot the function and look at the optimising value.  You should be able to see if the optimising value you have calculated is actually at a minimising/maximising point.  If your objective function is in higher dimensions then this gets trickier, but you can always hold some argument values constant (at the optimising point) and check the others with plots.