In order to evaluate the spiritual value of anything, we have to apply the "Regula Fidei", or "Rule of Faith".
Regula Fidei
A quick definition:
the rule of faith means something extrinsic to our faith, and serving as its norm or measure
Catholic Encyclopedia
Essentially, the Rule of Faith is the ultimate authority that is used to measure doctrines, practices, or beliefs (or other items in Christianity).
Ultimate Authority
Applying the Rule of Faith is much more tricky since it depends on what you consider the "ultimate authority". Sola Scriptura adherents, for example, consider the Bible to be the ultimate authority;
For Catholicism:
But since Divine revelation is contained in the written books and unwritten traditions (Vatican Council, I, ii), the Bible and Divine tradition must be the rule of our faith
Catholic Encyclopedia
Applying Regula Fide for Commentaries
Ultimately, when examining commentaries, we have to use the Regula Fidei to determine if a commentary is valid. For Sola Scriptura adherents, this means that we have to use the Bible to determine if a commentary is valid or not (which is often not easy). Fortunately, in Catholicism, there is a bit larger body of work to draw upon.
All commentaries come from a certain doctrinal standpoint. Often, a commentary (as others have mentioned) will note their doctrinal standpoint, but sometimes they will not. In these cases, it's most important to examine the Bible and Divine traditions to see if the commentary contradicts anything within the Bible or Divine traditions. If it does, then clearly the commentary should be avoided.