One of the best bakeries in San Francisco is Stella Pastry & Cafe. This bakery is in North Beach at 446 Columbus Ave. When I first moved to the city I discovered this little gem in North Beach. It is my favorite place for dessert after having dinner in Russian Hill. You can just hop on the 45 bus off of Union and take it all the way to Columbus. I recommend ordering the classic Napoleon pastry.
It is the best I have ever had. My second favorite choice is the cannoli. It almost compares to one in the North End of Boston at Mikes Pastry. This is still the best cannoli if you are ever in Boston.