As the holder of an option contract you can choose to exercise your option contract at any point before the expiry of the contract.
However, it is important that you might lose any remaining time value of the option if you exercise early. Also, consider any implications and transaction costs that might come with exercising the option compared to selling it on the market. For that reason it is most common to sell back the contract before expiry instead of exercising the contracts to capture any potential profit of the contracts.
You might consider exercising an option contract in a few key situations. One is when the option is deep in-the-money, meaning the stock price is much higher (for a call) or much lower (for a put) than the strike price. This allows you to lock in the value of the option. Another time to exercise is near the expiration date if the option is in-the-money, so you can either take possession of the stock or sell it at the strike price before the option expires. Additionally, you might exercise an in-the-money call option to capture an upcoming dividend.