This paper studies a pricing problem for a single-server queue where customers arrive according to a Poisson process. For each arriving customer, the service provider announces a price rate and system wait time. In response, the customer decides whether to join the queue, and, if so, the duration of the service time. The objective is to maximize either the long-run average revenue or social welfare. We formulate this problem as a continuous-time control model whose optimality conditions involve solving a set of delay differential equations. We develop an innovative method to obtain the optimal control policy, whose structure reveals interesting insights. The optimal dynamic price rate policy is not monotone in the wait time. That is, in addition to the congestion effect, i.e., the optimal price rate increases in the wait time, we find a compensation effect, meaning that the service provider should lower the price rate when the wait time is longer than a threshold. Compared with the prevalent static pricing policy, our optimal dynamic pricing policy improves the objective value through admission control, which, in turn, increases the utilization of the server. In a numerical study, we find that our revenue-maximizing pricing policy outperforms the best static pricing policy, especially when the arrival rate is low and drivers are impatient. Interestingly, the revenue-maximizing policy also improves social welfare over the static pricing policy in most of the tested cases. An extension to include heterogeneous customers reveal similar insights.