The right to refuse to give self-incriminating evidence in court is guaranteed in the Fifth Amendment to the Constitution of the United States. But "pleading the Fifth" isn't something to take lightly. Discuss the possible consequences thoroughly with your criminal attorney before using this strategy.
Pleading the Fifth may keep certain evidence out of the trial record, but in the process you may anger jury members. Even if you win the court case, the court of public opinion will assume refusing to answer a question on self-incrimination grounds means you're guilty of something.
Colonel Oliver North infamously invoked the Fifth Amendment during the Iran-Contra Congressional hearings in 1987. He was later convicted of falsifying and destroying documents and of obstructing a Congressional investigation.
In many cases, as with Colonel North, pleading the Fifth will only delay admission of evidence. Prosecutors start salivating whenever they hear it because they figure they're close to something tender. And they double their efforts to get to the heart of it.
Your lawyer in a criminal defense case may counsel you to plead the Fifth if your answer would constitute an admission of guilt. He or she may also recommend it if your testimony would link you to a series of events that would lead to prosecution. But this tactic should only be used in extreme circumstances and when you're confident the evidence can't easily be found through other channels.
Note that the rights against self-incrimination extend only to individuals. This means a company cannot invoke the Fifth Amendment for protection from subpoena of its records that may be incriminating.
Although there are some very legitimate reasons for invoking protection against self-incrimination, it's largely seen as a loophole for the guilty. If your attorney encourages this response, make sure it serves a well thought out strategy and only when the fate of the trial hinges on that evidence.