There is actually no single agreed upon way how to do this. As discussed by Carnot et al in Economic forecasting and Policy pp 215:
The other conceptual problem [in the cost-benefit analysis] concerns the discount rate. First, using discounting mechanically leads to putting less weight on more distant costs and benefits-much less, in fact, when the project has an impact far into the future. This may not be sensible, notably when the project has significant long-run environmental repercussions. Second, there is the issue of the choice of an appropriate discount rate. Opting for a market rate is not a simple solution, given the dispersion of market rates from which to choose. In fact, the discount rate used by private firms is often far above any bond rate, because it reflects high opportunity costs. In the public sector, it is usually lower, albeit still above bond rates, because of budget constraints. That said, the uncertainity about the right discount rate is more of an problem when analyzing the intrinsic costs and benefit of a given project than when comparing those of competing projects pursuing the same objective.
However, typically discount rate is set to be equal to the interest rate on government debt. For example, Congressional Budget Office (CBO) does this as it explains in its primer on how it provides fair value estimates. Nonetheless, as this report shows it will sometimes use different rates depending on the setting (e.g. different rates for military spending, or different rates if some are required to be used by regulation).
Some government bodies make an adjustment to this rate for a long term projects reflecting the issue discussed in the first part of the quote from Carnot et al (e.g. see this HM treasury report).
This is arguably not ideal, but as the quote above says, even though this can create inaccuracies in finding the true value of the project when you just compare two projects to each other, it is not a huge issue since you will use the same discount rate for both projects.