Comma before a dependent clause and the word 'respectively'
The sentence is correct as you have written it.
"Respectively" is a free modifier, modifying "with each state and territory having 12 and 2 senators" adverbially.
Free modifiers are always offset by commas. e.g. "Unfortunately, the rope broke" / "The rope broke, unfortunately."
See also this Online Writing course on Free modifiers: http://writingwithaesop.blogspot.com/2011/01/commas-and-free-modifiers.html