Yes, It does go away when It switches. Note, that Confusion can be Baton Passed.
This works like the ability Natural Cure and Shed Skin/Healer(I think), that gets rid of your Pokemon's status problems upon switching out. As Halcyonic Falcon has said, It works similar with all Secondary status effects.