Pipeline leakage of crude oil, refined oil or other petroleum derivatives can cause serious damage to the environment, soil, and more importantly, pose a serious threat to personal safety. The losses can be minimized to a degree by active control. Therefore, timely and effective control measures should be taken to minimize the leak volume whenever a pipeline leaks. However, the complexity of pipeline hydraulic systems makes it difficult to optimize control schemes for pipeline hydraulic devices under leak conditions, and existing studies rarely consider complex transient processes. This paper aims to establish a mixed integer linear programming model considering transient processes, hydraulic constraints, equipment constraints and flow constraints, and develop a detailed control scheme of the devices by the branch and bound algorithm. Moreover, it is the objective of the model to figure out the most optimal control plan to minimize the leakage. Experiments on a real-world liquid pipeline have proved the practicability and high reliability of the model.