In this paper, an inverse source problem for the time-fractional diffusion equation is investigated. The observational data is on the final time and the source term is assumed to be temporally independent and with a sparse structure. Here the sparsity is understood with respect to the pixel basis, i.e., the source has a small support. By an elastic-net regularization method, this inverse source problem is formulated into an optimization problem and a semismooth Newton (SSN) algorithm is developed to solve it. A discretization strategy is applied in the numerical realization. Several one and two dimensional numerical examples illustrate the efficiency of the proposed method.