High penetration of small-scale distributed energy sources into the distribution network increase negative impacts related to power quality causing adverse conditions. This paper presents a mathematical model that maximizes distribution network hosting capacity through optimal distributed generation capacity allocation and control and grid reconfiguration. In addition to this, the model includes on-load tap changer control for stabilization of grid voltage conditions primarily in grid operating conditions related to voltage rise problems, which can limit grid hosting capacity. Moreover, the objective function allows the possibility of energy transfer between distribution and transmission grids. The proposed model considers alternative grid connection points for distributed generation and determines optimal connection points as well as install capacity while considering network operating limits. The model is cast as a multiperiod second-order cone linear program and involves aspects of active power management. The model is tested on a modified IEEE 33 bus test network