After-sale service is an integrable part of marketing activities. The after-sale service experience of a consumer can be measured by the dynamic maintenance (DM) strategy used by the merchant, i.e., the instantaneous fractions of the maintenance cost paid by the merchant in the total maintenance cost at all time. This paper aims to develop an optimal DM strategy for a word-of-mouth (WOM) marketing campaign. First, we propose an individual-based WOM propagation model in which the effect of the DM strategy is accounted for. Second, we convert the original problem into an optimal control problem, where the objective functional stands for the expected marketing profit, each optimal control stands for an optimal DM strategy. Third, we derive the optimality system for the optimal control problem. By solving the optimality system, we get a potential optimal control. Next, through comparative experiments we conclude that the DM strategy associated with the potential optimal control outperforms most DM strategies in terms of the expected marketing profit. Therefore, we recommend this potential DM strategy. Finally, we examine the effect of some factors on the expected marketing profit for the potential DM strategy. Our findings help to enhance the marketing profit of a WOM marketing campaign.