Cytotoxic T cells kill cancerous and virally infected cells by injecting them with enzymes that break down the cell from the inside-out. Obviously it's quite important that they don't do that to healthy cells. The damage caused to the liver by hepatitis B virus is almost entirely down to these T cells trying to destroy cells they class as infected. So how do they do it?
T cells have molecules that stick out of their surface called T cell receptors. These recognise particular antigens on the surface of damaged or infected cells, signalling to the T cell that this is one to go for. The cytotoxic enzymes are held in vesicles called lysosomes inside the T cell. They sit on branches of the cytoskeleton, which is a bit like the cell's road network. These branches originate from the centrosomes, which are important for cell division.
When the cell comes across an antigen that activates it's receptor, the centrosome migrates to the receptor and docks at the site. All the lysomsomes can then easily be transported to the activated site. Once the lysosomes reach the site, they fuse with the cell membrane, spewing out their contents onto the surface of the damaged cell. Importantly these contents also contain proteins called perforins. These are little tubes that punch holes into the offending cell, letting the enzymes into the damaged cell.
Inside the cell, the enzymes start breaking down internal proteins and trigger the caspase cascade, which eventually leads to apoptosis. Cells recognise that once they are beyond a critical threshold of damage, they're better offer undergoing a controlled cell death as opposed to exploding damaging chemicals all over their neighbours.