When you choose to sell to open an option position, the buyer has the right to exercise his/her option. If the buyer exercises, you’re assigned. You can be assigned at any time between when you sell to open the option and when it expires, though you’ll typically be assigned on the day of the contract’s expiration if it’s in the money.
When you’re assigned, you have the obligation to fulfill the terms of the contract.
The only way to avoid being assigned on an option that you have sold is to buy the position back in the open market.