“Only if your alignment matches” vs. “not of an alignment that opposes your own”
There are two major cleric class features that are restricted based on your/your deity’s alignment: the domains you have and the spells you cast. Specifically, we have
A cleric can’t cast spells of an alignment opposed to his own or his deity’s (if he has one).
and
A cleric can select an alignment domain (Chaos, Evil, Good, or Law) only if [his/her] alignment matches that domain.
The way the alignment restriction is implemented is different for these two things. Spells must not be “opposed,” but domains must “match.”
For a Lawful Neutral alignment, “matching” alignments are Law, and “opposing” alignments are Chaos. Good and Evil are both neither matching nor opposing (you are “Neutral” with respect to those alignments). So, you can select the Law domain—your alignment matches it—but cannot select the Good or Evil domains (since you are Neutral with those, not matching), and you cannot select the Chaos domain (since you are opposed to that). On the other hand, the only spells you cannot cast are the ones with the Chaos descriptor—only those oppose your alignment. Both good and evil spells are available to you if you are Lawful Neutral. You cannot cast chaotic spells.
Casting a good or evil spell may constitute a good or evil act, which may cause your alignment to become good or evil over time. This is very much up to the DM, though; Pathfinder’s authors have some (really stupid, IMO) suggestions for it (roughly, “three strikes and you’re out”), but ultimately it’s going to be up to the DM.
Aligned spells from unaligned domains
So what if your Lawful Neutral cleric selects an unaligned domain that has a chaotic spell on it? For example, the 3.5e Bestial domain has were-doom on it, which is an Evocation [Chaos, Evil] spell. It is normally only available to chaotic and/or evil clerics since the only deities that offer it—Karaan, Malar, and Yeenoghu—are all Chaotic Evil, but a Lawful Neutral cleric of an ideal might be able to have it. Can this Lawful Neutral cleric cast were-doom?
D&D 3.5e—we don’t know for sure, but almost certainly “No”
However, there are other domains that have aligned spells. Strictly speaking, it’s not really defined by the rules whether you can cast these with an opposing alignment:
Each domain gives the cleric access to a domain spell at each spell level he can cast,
says a cleric can cast the spell, while
A cleric can’t cast spells of an alignment opposed to his own or his deity’s (if he has one).
says a cleric can’t. The rules don’t clearly lay out a sense of which of these rules is “primary” here.
That said, there are a number of clues that the alignment requirement still applies to domain spells. The most significant of these is that the domain spells feature says the domain gives the cleric access to the spells—it does say “he can cast,” but the emphasis on “access” suggests that this isn’t absolute. Certainly, we expect that the cleric must still provide the needed components (chants, gestures, materials, etc) in order to cast them; the “he can cast” doesn’t override all the usual requirements for spellcasting. It likewise should not overrule the alignment restriction that clerics have on spells.
Even though you can’t cast the spell, this doesn’t necessarily mean you should never choose a domain with an aligned spell that opposes yours. You could select the domain and just not cast that spell; you get two domains, after all, so you could always just cast the spell from the other one. If the rest of the domain is strong enough, this could be fine.
Pathfinder—much more clearly “No”
While Pathfinder copied most of its core text directly from the 3.5e SRD, they did edit things here and there. It turns out the text of domain spells changed a little, in a crucial way:
Each domain grants a number of domain powers, dependent upon the level of the cleric, as well as a number of bonus spells. A cleric gains one domain spell slot for each level of cleric spell she can cast, from 1st on up. Each day, a cleric can prepare one of the spells from her two domains in that slot. If a domain spell is not on the cleric spell list, a cleric can prepare it only in her domain spell slot. Domain spells cannot be used to cast spells spontaneously.
Nowhere in here does it say “the cleric can cast the spell.” It says she can prepare it, which implies that she can cast—as long as she could otherwise cast that spell. But now the rule about aligned spells clearly says she cannot cast it, so she can’t. There is no longer any argument about one thing saying a cleric can and another thing saying the cleric can’t.
As in 3.5e, the cleric can still choose the domain (unless that is aligned, too), if the rest of the domain is good enough and she is comfortable just always casting her other domain’s spell out of that domain slot.