If open interest is 0, who will you buy an option contract from? And how the price is calculated?
Also, initially, how the option contract price is determined?
Options firstly have to be listed on an exchange. Once listed, the exchange asks their Market Makers to post two-sided quotes in that option series (for example, by requiring in their rules that the market makers members have to quote in each of the listed series 60% or 75% of the time the series is open for trading). Those that do not meet these quoting requirements get fined.
Until the first trade occurs, the open interest is zero. When the first trade occur, the seller of the option (who doesn't hold a position) is writing the option. At that point the open interest would increase by the number of contracts sold and purchased.
The market maker determines the price based on a number of factors, which ultimately reflect the probability of the stock price being above or below the strike price of the option at or before expiration (plus some financing cost for hedging). The Black Scholes model is what first enabled options to be priced reliably and regularly traded (though applies only to 'European' style options - those that have a single exercise date). Other more complex methods are used to price American style options that can be exercised on any date up to and including expiration.
The methods used to price the options initially are the same as those used to price the options after the initial trade has occurred. From a market maker's perspective, pricing another series is not a lot different from pricing existing series - simply that the strike price and or expiration date is diferent. Rerunning the pricing calculation with the strike price or expiration date that is different is relatively straightforward.
You are buying it from another investor who wishes to take the other side of the trade. This is not really different from when the open interest is 100 , 1000, 5000. When you see that, it means there are XX contracts that exist. You're not buying/selling one of those when you "buy to open". Unless an existing contract holder wishes to sell, you are just paired up with a new investor wishing to open a new contract, just like you.
(Some options also have "market makers", individuals who make a living out of being the 'other' side of the trade when there is low liquidity.)
What open interest does tell you is how strong investors' desire to trade is. High open interest implies high liquidity, and a tighter bid/ask.
As Joe said, you are buying it from another investor who wishes to take the other side of the trade. In the absence of that trader, the market maker is the counter party. He makes a two-sided market and is willing to buy and sell those options at all times.
Option pricing is determined by an option pricing formula. At any moment in time all but one variable is known: strike price, underlying price, time remaining until expiration, dividend amount and date (if any), and carry cost. The only variable that is unknown is the volatility input. Other than the very first day ever that options trade, it's ballpark value is known from all other option series (same and/or different expirations).
Another pricing mechanism is arbitrage strategies such as conversions and reversals that inextricably link the value of same series options. So if the value of the put is known, that of the call can be calculated (and vice versa).