Updated March 11, 2016
Even without any reason to suspect that you've done anything wrong, a police officer can approach you to ask questions and ask to search you or your objects (such as a purse or briefcase). As long as the officer doesn't suggest that you are legally compelled to talk or agree to a search, the officer has done nothing wrong. (United States v. Drayton, 536 U.S. 194 (2002).) At the same time, you generally aren't required to answer a police officer's questions or allow an officer to search your person or your belongings.
(This article discusses general constitutional principles; make sure to check out our note on the importance of state law.)
Unless a police officer has "probable cause" to make an arrest, "reasonable suspicion" to conduct a "stop and frisk," or a warrant, a person generally has the legal right to walk away from the officer. However, there's often at the time of the encounter no real way to know what information the officer is relying on. An officer might have information that provides a valid legal basis to make an arrest or to conduct a stop and frisk, even if the person stopped is actually innocent of any wrongdoing. So, an officer might be justified in forcibly detaining an innocent person who starts to leave the scene of an interview.
Common sense and self-protection suggest that people who intend to walk away from police should first make sure that the officer does not intend to arrest or detain them. One might say, "Officer, I'd prefer not to talk to you right now. You won't try to stop me from leaving, right?" If the officer replies that you are not free to leave, you should remain at the scene and leave the issue of whether the officer had the necessary legal basis to detain you for the courts to determine at a later time.
(For more information on speaking to the police, including what can happen if you say nothing, see Invoking Your Right to Remain Silent.)
A "Miranda warning" is required only if a suspect is in custody and the police interrogate the suspect. In other words, both "custody" and "interrogation" have to occur for Miranda rights to kick in. One upshot of this requirement is that a statement by a person who is not in custody, or a statement by someone who is in custody that's volunteered rather than made in response to police interrogation, is likely admissible in evidence even if no Miranda warning was given.
Example: Officer Dave Bouncer is investigating a barroom brawl. The bartender indicates that a patron named Bob Sawyer might be able to identify the instigator of the brawl. When Officer Bouncer interviews Bob, Bob makes statements implicating himself in the brawl. Officer Bouncer did not read Bob his Miranda rights. Nevertheless, if Bob is charged with a crime concerning the brawl, his statements to Officer Bouncer will probably be admissible as evidence. At the time Officer Bouncer spoke to Bob, Bob was not in custody. Thus, the evidence may be admitted even though Officer Bouncer never gave Bob any Miranda warnings.
People can sometimes clear their names as well as help the police find the real perpetrators of a crime by answering a few straightforward questions. For example, perhaps a possible suspect can show unequivocally that he was at dinner with a friend at the moment a crime was committed. On the other hand, many criminal defense attorneys would say that suspects should almost never talk to the police without consulting counsel first. (For some of the potential downside of talking, see this article on speaking to the police.)
People can sometimes make life easier for themselves by cooperating with police officers—as long as they don't have a good reason not to. "Contempt of cop" has resulted in the arrest and even physical injury of more than one innocent person. When innocent people who are pulled over or questioned by police officers stand on their rights too forcefully, events can sometimes get out of control rather quickly.
If the police want to talk to you and you have the chance, consider consulting an experienced criminal defense attorney. A knowledgeable attorney can not only advise you as to handle law enforcement, but also explain the ins and outs of the applicable law in your jurisdiction. For instance, a lawyer can explain to you the potential consequences—both legal and practical—of lying to or not cooperating with the police.