District heating systems based on industrial waste heat play an important role in using energy efficiently. Combined with a thermal energy storage technology, such as pressured-water tanks, they have the potential of significantly reducing greenhouse gas emissions as well. However, installing thermal energy storage requires capital and, therefore, it is important to find an optimal design that balances the benefits of energy storage with the costs of installing such system. In this work we formulate a dynamic optimization model for designing a thermal energy storage tank based on operational conditions and apply it to a case study using historical data from a district heating system that recovers heat from an industrial plant in Norway. We found that a relatively large tank (greater than 5000 m3) would be necessary to store all excess energy provided by the plant that cannot be immediately used for the period and input data considered. However, the results can be used to investigate uncertainties and their effects on the optimal tank volume and return of investment.