Upon departure from the Delta airspace of the city i was visiting 60 nm north of my home field, I contacted center and told them I wanted vfr flt. flwng. for a Bravo transition to get me back to my home field. They gave me a transponder code and told me the altimeter settings, etc. Since it was such a beautiful day, this route would bring me over Sausalito, the Golden Gate Bridge, the city of San Francisco, just west of busy KSFO and along 101 down the SF peninsula. Center handed me off to approach which told me to get down to 2,000' over the City and remain west of 101, then I was handed off to SFO tower who instructed me to descend to 1,500' due to opposite direction traffic. As I was exiting Bravo, SFO tower told me I was leaving Bravo, to squawk vfr and gave me the freq. for the tower I was going to land at. I switched the transponder to 1200 contacted the Delta tower, my destination. They told me to ident, then gave me landing instructions, but questioned me as to why i was squawking 1200, because usually you keep the bravo code all of the way into landing. My experience has been that tower/center, etc. will explicitly tell you to stay on the beacon code they assign you if that's what they want, even if you are exiting their airspace, or they say you are exiting bravo,etc. squawk vfr....My question is: Wouldn't it be much simpler if they tell you to remain on this code? Maybe I missed something from the tower, but I know they DID NOT tell me to remain on the discrete code I had been assigned ...There was no harm/no foul, just an observation.