In this paper, a reflective terahertz reconfigurable multifunctional coding metasurface based on topology optimization using liquid crystal (LC) is presented. First, the LC metasurface unit is topologically optimized using the NSGA-II multi-objective optimization algorithm. By applying the bias voltage to dynamically adjust the dielectric constant of the LC, the metasurface unit is capable of 2-bit coding at the frequency of 0.67 THz. Then, based on the designed metasurface unit, the array arrangements of the coding metasurface are reversely designed, which makes the metasurface realize flexible control and dynamic switching between beam assignment and vortex beam generation. The results show that for the beam assignment, the single-beam and multi-beam control can be realized with the reflected electromagnetic waves at continuous arbitrary angles in the range of elevation angle of 40° and azimuth angle of 360°. Moreover, the elevation angle and azimuth angle of each beam in the multi-beam can be controlled independently. Using the Fourier convolution addition operation, the control range of the single-beam elevation angle can be expanded. For the vortex beam, the single vortex beam and the multi-vortex beam can be generated in the range of elevation angle of 40° and azimuth angle of 360° with topological charges l=±1, ±2, ±3 at arbitrary angles. This provides flexibility and diversity in the generation of vortex beams. Therefore, the proposed terahertz LC metasurface can realize flexible control of reconfigurable functions and has certain application prospects in terahertz communication, phased array radar, and vortex radar.