I understand the logic for call options. When dividends exceed the time value left, then it is profitable to early exercise a call.
But the same does not hold for a put. So, when to early exercise a put?
When you want the transaction to be concluded in the current year vs an expiration in the next year.
When you exercise a put, you get paid the strike price immediately. So you can invest that money and earn some interest, compared to only exercising at expiry.
So the benefit to exercising early is that extra interest. The cost is the remaining time value of the option, along with any dividend payments you miss.
As @JoeTaxpayer points out, there might be tax considerations that make it better to exercise at one time rather than another. But those would likely be personal to you, so if the option would intrinsically have more value unexercised, in many cases you could sell it on rather than exercise it. The exception might be if it wasn't very liquid and the transaction costs of doing that outweighed the theoretical value.
There are multiple issues in your question as well as in the answers/comments that you received.
If a deep in the money option has time premium remaining, it makes no sense to exercise it since you would be throwing away the time premium by doing so. The exception to this would be if your closing commission costs exceed that time premium.
With deep ITM options, the bid is often below intrinsic value. Sometimes it can be as much as 25-35 cents, or more. You could try for some price improvement with your STC order but there is no incentive for the market maker or anyone else to give you the full intrinsic value. While waiting for a better fill, the price of XYZ could change and you could give back some of your intrinsic value.
To avoid this haircut, you could perform the same Discount Arbitrage that a market maker would do. Assume that it's a deep ITM call. Short the stock and then exercise the call. That locks in the intrinsic value and avoids the haircut (short the stock first to avoid slippage). Example:
XYZ is $40 Sep $35 call is $4.80
The intrinsic value of the call is 5 points. Short the stock at $40 and exercise the call to buy the stock at $35 (+ $40 - $ 35) = $5 (20 cents better than selling the call to close).
The trade off is that by holding the call to get the dividend(s), you risk losing a lot of intrinsic value if the stock collapses so your decision should be based on your outlook for the underlying, not the possibility of receiving a dividend.
It is a misconception that when dividends exceed the time value left, then it is profitable to early exercise a call. The dividend arbitrage exists for the ITM put, not the ITM call. Example:
XYZ is $40 Sep $45 put is $5.30 ex div is tomorrow and it is 50 cts
Buy stock, buy put, exercise after ex-div
Why doesn't this exist for the ITM call? Share price is reduced by the stock exchanges by the amount of the dividend so there is no profit there. If you exercise a call with time premium remaining, you throw away the time premium and the so called arb is done at a loss.