van der Waals heterostructures based on two-dimensional (2D) materials have attracted tremendous attention for their potential applications in optoelectronic devices, such as solar cells and photodetectors. In addition, the widely tunable Fermi levels of these atomically thin 2D materials enable tuning the device performances/functions dynamically. Herein, we demonstrated a MoTe2/BP heterostructure, which can be dynamically tuned to be either p-n or p-p junction by gate modulation due to compatible band structures and electrically tunable Fermi levels of MoTe2 and BP. Consequently, the electrostatic gating can further accurately control the photoresponse of this heterostructure in terms of the polarity and the value of photoresponsivity. Besides, the heterostructure showed outstanding photodetection/voltaic performances. The optimum photoresponsivity, external quantum efficiency, and response time as a photodetector were 0.2 A/W, 48.1%, and 2 ms, respectively. Our study enhances the understanding of 2D heterostructures for designing gate-tunable devices and reveals promising potentials of these devices in future optoelectronic applications.