This interesting wasp is an Oak Gall Chalcid (Torymus californicus) The long black thing is an ovipositor.
Answer found at San Francisco Chronicle's sfgate home guides :
Larval California Gall Wasp
As soon as they hatch, larvae begin feeding. The oak begins producing a different kind of tissue in response to their feeding. The gall begins to form around the larvae, first showing in early winter as a small nodule covered by bark. In early spring the gall emerges through a slit in the bark and usually reaches full growth in July. The gall furnishes the larval gall wasps with good nutrition and a protected place for them to grow.
Associated Animals
Some insects live at the benefit of the California gall wasp and the apple galls they produce. Small chalcid wasps (Torymus californicus and Baryscapus gigas) parasitize the California gall wasp larvae. Female wasps insert their eggs into the grubs living within the gall, and their larvae eat the California gall wasp larvae. A moth larva (Cydia latiferreana) uses the oak apple gall as food, and it in turn has a wasp parasite. The adult gall wasps serve as food for spiders, lizards, and birds such as nuthatches, chickadees, kinglets and vireos.
Now you know the rest of the story. To dig deeper, check out these sites: