組織情報のIsSandboxという項目を参照することで、本番環境かどうかを判定することが可能のようです。
組織情報を参照するSOQL select Name, OrganizationType, InstanceName, IsSandbox from Organization