The question you are asking concerns the exercise of a short option position. The other replies do not appear to address this situation.
Suppose that Apple is trading at $96 and you sell a put option with a strike price of $95 for some future delivery date - say August 2016. The option contract is for 100 shares and you sell the contract for a premium of $3.20.
When you sell the option your account will be credited with the premium and debited with the broker commission. The premium you receive will be $320 = 100 x $3.20. The commission you pay will depend on you broker.
Now suppose that the price of Apple drops to $90 and your option is exercised, either on expiry or prior to expiry. Then you would be obliged to take delivery of 100 Apple shares at the contracted option strike price of $95 costing you $9,500 plus broker commission. If you immediately sell the Apple shares you have purchased under your contract obligations, then assuming you sell the shares at the current market price of $90 you would realise a loss of $500 ( = 100x($95-$90) )plus commission. Since you received a premium of $320 when you sold the put option, your net loss would be $500-$320 = $180 plus any commissions paid to your broker.
Now let's look at the case of selling a call option. Again assume that the price of Apple is $96 and you sell a call option for 100 shares with a strike price of $97 for a premium of $3.60. The premium you receive would be $360 = 100 x $3.60. You would also be debited for commission by your broker.
Now suppose that the price of Apple shares rises to $101 and your option is exercised. Then you would be obliged to deliver 100 Apple shares to the party exercising the option at the contracted strike price of $97. If you did not own the shares to effect delivery, then you would need to purchase those shares in the market at the current market price of $101, and then sell them to the party exercising the option at the strike price of $97. This would realise an immediate loss of $400 = 100 x ($101-$97) plus any commission payable. If you did own the shares, then you would simply deliver them and possibly pay some commission or a delivery fee to your broker. Since you received $360 when you sold the option, your net loss would be $40 = $400-$360 plus any commission and fees payable to the broker.
It is important to understand that in addition to these accounting items, short option positions carry with them a "margin" requirement. You will need to maintain a margin deposit to show "good faith" so long as the short option position is open. If the option you have sold moves against you, then you will be called upon to put up extra margin to cover any potential losses.