In this paper, we investigate pilot allocation problem in two-tier time division duplex (TDD) heterogeneous network (HetNet) with mMIMO. First, we propose a new pilot allocation scheme to maximize ergodic downlink sum rate of macro users (MUs) and small cell users (SUs), where the uplink pilot overhead and cross-tier interference are jointly considered. Then, we theoretically analyze the formulated problem and propose a low complexity one-dimensional search algorithm to obtain the optimum pilot allocation. In addition, we propose two suboptimal pilot allocation algorithms to simplify the computational process and improve SUs' fairness, respectively. Finally, simulation results show that the performance of the proposed scheme outperforms that of the traditional schemes.