In the present paper, an optimal control problem constrained by the tridomain equations in electrocardiology is investigated. The state equations consisting in a coupled reaction-diffusion system modelling the propagation of the intracellular and extracellular electrical potentials, and ionic currents, are extended to further consider the effect of an external bathing medium. The existence and uniqueness of solution for the tridomain problem and the related control problem is assessed, and the primal and dual problems are discretized using a finite volume method which is proved to converge to the corresponding weak solution. In order to illustrate the control of the electrophysiological dynamics, we present some preliminary numerical experiments using an efficient implementation of the proposed scheme.