Whenever possible, you should try and cite the original source to make sure proper credit is attributed, especially if the original work is not well known enough to constitute "textbook material". For example, you can probably skip citing Einstein's original paper on special relativity and cite a newer textbook instead, where current standard notation and more context to the theory is provided.
Some times citing the derivative work can add to the discussion in the way of a simplified treatment over the original, further clarifications, notes on implications, and so on. Keep in mind that original work is often obscure, may not yet incorporate terminology or concepts that became mainstream after it was published, etc. In these cases I would recommend citing both the original and the derivative work. In my own papers I have used sentences such as "... our treatment is based on the theory presented by Doe and collaborators in their seminal paper , later reviewed more pedagogically by Smith ." Some journal editors will ask you to remove citations if they think they are redundant. This usually applies to obvious cases such as "... according to literature sources [1-25]..", but I guess an occasional picky editor might ask you to remove some of the references even if you're using them reasonably. In that case you need to judge by yourself if its worth insisting on keeping all the citations.
To summarize, when it doubt, I think it's best to err on the side of inclusion and make sure 1) that due credit is given to all the authors that deserve it and 2) that previous work you rely on for your study can be traced back following the items provided in the list of references.