To support various service requirements such as massive Machine Type Communications, Ultra-Reliable and Low-Latency Communications in 5G scenario, Network Function Virtualization (NFV) plays an important role in the 5G network architecture to manage and orchestrate network services. As the key network function responsible for mobility management, Access and Mobility Management Function (AMF) can be deployed flexibly at the edge of the radio access network to improve the performance of mobility management based on NFV. In this paper, the optimal placement of AMF is addressed based on Deep Reinforcement Learning (DRL) in a heterogeneous radio access network, which aims to minimize the network utility including the average delay of mobility management requests at AMF, the average wired hops to relay the requests and the cost of AMF instances. By considering time-varying features including user mobility and the arrival rate of user mobility management requests, an AMF optimal placement approach is proposed for the long term optimization. Simulation results show that the performance of the proposed DRL based AMF optimal placement approach outperforms that of the baselines.