The difference is that race is a protected class at the Federal level, so no state can make a tax code that specifically discriminates on the basis of race. Sexual orientation is not a protected class at the Federal level, but it is at the state level in California. As such, if California finds that an organization violates their discrimination code with regards to sexual orientation, they can revoke a tax exemption specifically within their state.
Using an example of a non-protected class of people, let's say the obese (obesity not being a protected class from discrimination at the Federal or state level): If Alabama were to revoke tax exemptions for any non-profit organization set up to help obese people, they would be perfectly within their rights to do so (although it's difficult to think of a non-profit that would specifically be set up to benefit the obese...). The point is, if something is defined as discrimination at the Federal level, no one can discriminate on that basis (hence the reason the Scouts couldn't refuse black applicants). If something is defined as discrimination at the state level, that state can set specific rules, including in the tax code, to punish behavior inconsistent with local laws.