Your description of sonata-allegro form is not right. Theme II of the exposition is when the tonic moves to the dominant (or relative major for sonatas in minor key). The development will move through a number of different keys and usually end with a long dominant preparation back into the recapitulation. The recapitulation is in the tonic and stays in the tonic for theme II.