Sorceries can be cast any time you have priority during a main phase on your turn, provided the stack is empty at that moment. This applies equally to your first main phase and your second main phase (also called the postcombat main phase). CR 307.1 states that a player may cast a sorcery only during a main phase of their own turn when the stack is empty.
The second main phase is a distinct step in the turn sequence that occurs after the end of combat step (CR 505). When you receive priority at the start of that phase with an empty stack, all sorcery-speed actions — including casting sorceries, playing lands, and activating abilities that are sorcery-speed — become available to you just as they were in your precombat main phase.
Having priority is the key requirement. Priority is governed by CR 117. At the beginning of each phase and step, the active player (you, on your turn) receives priority. If the stack is empty when you receive it, sorcery timing is met immediately.
Concrete example: You attack with your creatures, combat resolves, and the game moves to your second main phase. You receive priority with an empty stack. You may now cast Shatter (a sorcery) to destroy an opponent's artifact — this is completely legal, exactly as if you had cast it before attacking.
There is no restriction that limits sorcery casting to only the first main phase; both main phases are equal in this regard (CR 505.1).
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.