We propose a new optimal control model of product goodwill in a segmented market where the state variable behaviour is described by a partial differential equation of the Lotka-Sharp-McKendrick type. In order to maximize the sum of discounted profits over a finite time horizon, we control the marketing communication activities which influence the state equation and the boundary condition. Moreover, we introduce the mathematical representation of heterogeneous electronic word of mouth. Based on the semigroup approach, we prove the existence and uniqueness of optimal controls. Using a maximum principle, we describe a numerical algorithm to find the optimal solution. Finally, we examine several examples on the optimal goodwill model and discover two types of marketing strategies.