The BlackScholes Model
The cost of an option is generally calculated by what is known as the BlackScholes model. This was first published in the Journal of Political Economy in 1973. It estimates the price of an option over time.
Give certain assumptions, it then uses seven factors to calculate the price.
The Factors

Stock Price: If you have an agreement to buy a stock at a certain price in the future then, if the actual price of the stock is higher at that time, obviously your investment is worth more.

Strike Price: This is the agreed upon price of the option. It is the amount at which the stock must be bought or sold according to the agreement.

Interest Rates: The market’s interest rates have a small but distinct effect on the price of an option and will affect your profit. If interest rates rise, then the value of a call option will rise, and value of a put option will fall.

Time to Expiration: Over the lifetime of the option, it will start to lose value. When there is a long time until the time to expiration, it has the potential to move around and thus higher value.

Dividends: Since owners of options do not receive dividends, when the companies release dividends the value of the option fluctuates.

Type of Option: This is simple enough. Depending on whether you are holding a call option or a put option, each factor will affect the price differently for you.

Future Volatility: Volatility of a stock cannot be known from before. ‘Implied’ volatility is used, which is basically an estimate of how traders believe the stock will move over time.