I am considering writing and selling adventures and/or a campaign setting for Dungeons and Dragons v3.5 and I am wondering if it is legal to do so. Also what am I allowed to use from the official sources and do I need to contact Wizards of the Coast?
Anything you find in the SRD is Open Gaming Licence content and thus free to use so long as you abide by the terms of the OGL. You'll note that it does not contain XP or Wealth-By-Level rules, and you'll also notice that it doesn't really contain fluff; those rules (and the fluff) are still WotC's property and cannot be used. Beyond that, you're perfectly free to use any of the rules in that SRD, edit them, homebrew for them, and add your own fluff to them - in point of fact, that's how Pathfinder, World of Warcraft D20, and many other D20 systems got created and legally sold at profit. However, you are still not permitted to reference D&D in your product at that point (it's a D20 system release, but D&D itself remains the property of WotC, with whom I assume you are not affiliated).
Yes, and the law says you don't actually need the Open Game License to do it. But, You probably need to use the OGL anyway because the world is crazy.
The OGL is the legal vehicle that most publishers used during the d20 craze, and is what Pathfinder uses, to be "compatible with" D&D 3rd Edition; it was given by Wizards of the Coast during their experiment with open source content. They've since given up on that sort of thing.
First, the law says you can do it without the OGL:
It's never infringement of intellectual property to be compatible with an existing game's rules mechanics, other things being equal. Game mechanics can't be copyrighted. This is why so many other games look a lot like D&D and never had to pay D&D a dime (how many games have hit points and classes and levels?). Famously, WotC had to patent a bunch of stuff for Magic: The Gathering for this reason (such as tapping a card to show it's used up for the turn). I'm pretty sure there are no patents for D&D rules mechanics.
You can even say "This work is compatible with D&D 3rd Edition published by Wizards of the Coast," provided you also add a disclaimer, eg "but this work is not associated nor approved by Wizards blah blah blah." That's not infringing on their trademarks. If it was, Ford could control who gets to make oil filters that fit their vehicles, or could prevent people from putting "Fits a 2009 Taurus" on the box!
But, you may infringe a literary or artistic copyright (the PHB's textual content and artwork), or trademarks. So you can't just quote verbatim from the PHB, nor reuse that badass picture of Tordek refusing to be eaten by a dragon. Say, if you reference hit points or rolling damage with a die code, that's not infringing, but if you discuss the history of the city of Greyhawk or certain spells that contain the names of trademarked characters ("Bigby's Interposing Hand"), that's infringement.
But you should use the OGL because the world is crazy:
Wizards of the Coast's Lawyers of Social Domination Through Legal Harrassment +3 could come after you anyway, because the way intellectual property is protected in the modern world has gone completely crazy:
What you're willing to brave in terms of harrassment and litigation is up to you, but it's awfully telling that just about everyone who's published D&D material in the modern era has used the OGL to do it.
See, even though you're following the letter and spirit of the law, copyrights are civil rather than criminal which means you have no right to public (free) defense counsel nor presumption of innocence. In other words, copyright vultures with deep pockets can just force you through the vehicle of legal fees and hassle into doing what that they want you to do.
So yeah, I'd use the OGL. But the full story is rather more complex than "just use the OGL."
It depends on what you want to use and how you want to use it. As Lord_Gareth mentioned, all of the content from the System Reference Documents are available under the Open Game License. If you write your adventure and setting in a sufficiently generic way, you may not need to bother with the OGL.
The answers for Copyright of Existing Systems might also be of interest to you.