No, you do not need to buy two licenses.
You can buy a single license for your actual domain that is going to be used for your production site. You can use the same license key for the development website on localhost. Moreover, the same license key will be valid for all the subdomains of your main licensed domain. So you can host your development / staging site on one of the sub-domain of the licensed domain.
For example, if your production domain is http://www.example.com/, then you can host your staging site for any of its sub-domain, like http://dev.example.com/ or http://beta.example.com/ or any other sub-domain or on your localhost.