While sunblock is always a good idea, it is especially important as your scar in healing after surgery. In the early postoperative period, it is advisable not to have direct sun exposure on your incisions and thereafter sunblock is imperative to avoid excessive pigmentation in the scar line.
Typically just do whatever your surgeon has instructed. Each surgeon has different preferences that work for them. For my patients I don't require staying indoors at all. Only that they avoid straining, avoid sun on the incision, and that they ease back into activities.