We give an extension of the maximum principle and of the transversality conditions for a class of optimal control problems for a system of a parabolic equation and an ordinary differential equation in a Hilbert space. In particular we consider the time optimal problem for some of these eystems. As an application we study the optimal control of the diffusion of a clase of epidemics.This paper waa initially motivated by the study of the optimal control of the diffusion of a class of manenvironment-man epidemics. The diffusion happens according to the following mode1,which has been exhaustively studied by V. Capasso (and his coworkers):R is an open bounded subset of R2 whose boundary BR is sufficiently smooth and is the union of two disjoint curves I'l, rz, where yl(t, z) and yz(t, z) represent respectively the density of infective agent and infected people at the time t in the point z and w1 = wl(t,z) and wz = uz(t,a) are the control variables and respectively represent the factors of reduction of the diffusive effects of the epidemics which are produced by suitable sanitation program in the habitat R and on rl . (For a complete description of such a model see [l] ,[4] ,[5],[6] and the references therein ). The costs of the epidemica and of the sanitation pro-JET hz(wZ(f,a)) and obviously the purpose of the public authorities is to choose a sanitary strategy through the time interval [O,T] , which allows them to "win the diffusion of epidemic ", (in the sense that at the time T the total infected population haa to be sufficiently small , i.e. Jn &(T, z) dz 5 &= preassigned positive constant), in order to minimize the total coat. A variant of this problem waa to consider the final time T unknown and for example to look for the controls w1 , wz which allow us to win the diffusion of the epidemics, (i.e. J,yl(T,z)dz 5 J z ), with acceptable costs (i.e.grams had the form J& f(w(t,z)) 9 &. hl(wl(t, .)) and J,-phl(~l(t,z))dzdt 5 CI,J& h (~( t , z ) ) d z d t 5 cz and JQI f ( y l ( t , 2)) dzdt 5 cg ) in the minimum time.These problems motivated us in the necessity of extending the Pontryagin maximum principle and the transversality conditions to optimal control problems of the form To minimize tbe functional J(T,z,u) = O(T,z(T)) , z = ( 2 1 ,~~) over tbe set of tbe solutions (. . e. in (0,T'J ) of the system Z : ( q + AZl(t) = fl(4 Zl(t), Z z W , u(t)) 2 x 1 ) = fZ(C zl(t)t zz(t), 4 t ) ) Zl(0) = zf , Z l ( 0 ) = z;, (1) (zi(T), zz(T)) E B C X = Xi x Xz, (2) { satisfying the constraint on the final state where XI , Xz and H are real separable Hilbert spaces with H densely embedded in X I , the operator A : H + H' is linear continuous coercive and selfadjoint, the control set U is a subset of a Banach space 2 , and the mappings 0 : [O,+oo]xX -+ R a n d f = (f1,fz) : [O,+oo]xXxU + H' x Xz satisfy suitable differentiability assumptions. Now it is well known (see [2,p.251]) that the Pontryagin maximum principle cannot be extended in general to optimal control problems for evolution equations in infinite dimensional vector sp...