Suppose a stock is currently at $100, and I own a call option with a strike price of $150. Suppose I choose to exercise this option. Who is the lucky person that will get a free $5000? How is that person chosen?
The option clearing house (most likely the The Options Clearing Corporation), the one that guarantees the derivative contracts will pick one of the clearing member accounts (i.e. broker), which in turn will randomly pick an account that sold that option.
Now, I'm not sure in which situation anyone would chose to do this, but the question is valid, although would be more relevant in the case of deep, in the money, long options.
The OCC (in the US) is the counter-party for all options transactions. It notifies each clearing member who holds positions in the option in question who is being assigned. The assignment is performed using a random procedure.
It is up to the clearing member to have their own policies defining which of their customers will be assigned in such a situation. The only regulatory requirement is that they abide by their policies.
Your broker may be a clearing member at the OCC, or they could have a relationship with another broker that clears for them, in which case your broker's policies would also apply to those options that have been assigned to your broker by their clearing member.