If we're specifically talking about the Red Scare of the 1940s and 1950s, then a selected passage of this answer I wrote about McCarthyism might be of interest:
There's a difference between attempts to uncover Soviet espionage and uncover Communist party members or sympathizers. While both went on at the time, they technically were distinct: often, the fear with American Communists or Communist sympathizers is that they would use positions of influence to propagate or support Soviet objectives: this was a big fear when the Red Scare hit academia, with suspected communists being forced to submit loyalty oaths, and major academic administrators such as President Charles Seymour of Yale guaranteeing that no Communist would be allowed to teach there. It was less a matter of Soviet spies stealing secrets and more a matter of educators taking their talking points from the Soviet government and supposedly surrendering their independence of thought.
This type of anti-Communism wasn't strictly a matter of the political right, although clearly figures on the right (such as William Randolph Hearst and the up-and-coming Richard Nixon) banged that drum and made political hay from it. American liberals and leftists also turned against Communists as a "foreign" force in this period, with trade unions severing ties to Communist allies, the NAACP expelling Communist-influenced chapters, and Arthur Schlesinger denouncing communism (and equating it to homosexuality for good measure).
A major example of this would be the prosecution of major Communist Party leaders starting in 1949, in what are known as the "Smith Act Trials". As the name notes, the leaders of CPUSA were not prosecuted as spies, but for violating the 1940 Smith Act, ie calling for the violent overthrow of the US government.
Espionage activities were a part of the concern in this period, but only a part. The FBI had raided the office of Amerasia, a newspaper run by the Communist Party of the USA in June 1945, arresting members there, as well as a China specialist in the State Department. Ultimately the specialist was released for lack of evidence, and the editors were released because the FBI had illegally raided the office (they received fines for possession of US government documents instead). In 1946, Igor Gouzenko, a clerk at the Soviet embassy in Canada, defected and provided evidence that the Soviets had spied on atomic research programs in Canada and elsewhere - but this also never resulted in any arrests.
Another point where the history gets blurred is in disentangling McCarthy's Communist hunting (which went from February 1950 until his censure by the Senate in December 1954) with wider investigations into Communist influence by the US government. The House Un-American Activities Committee (HUAC), notably had public hearings into the influence of Communists in Hollywood in 1947, which resulted in studios blacklisting hundreds of suspected Communists and sympathizers.
1947 also saw the signing of Executive Order 9835 by President Truman, establishing "Loyalty Boards" in federal government agencies to review employees for suspected disloyalty: sabotage, treason, espionage, advocacy of violent revolution, performance of duties "so as to serve the interests of another government", or affiliation with any group "designated by the Attorney General as totalitarian, fascistic, communistic, or subversive." Investigating employees for suspected homosexuality was in effect also part of that remit, as it was considered a liability in that closeted people were vulnerable to blackmail. By 1952, 1,200 federal employees had been dismissed, and 6,000 resigned, but no one was proven to be a spy or a saboteur.
So, what to draw from all of that? Being a vocal fan of communism and denouncing capitalism would certainly draw some negative attention to you. But it really depended on where you were doing this, and perhaps more importantly what sorts of institutional connections and memberships you would have. Being a cook, or a janitor, or a store-owner complaining about capitalism would not get major attention on you compared to being an Ivy League professor, a Hollywood scriptwriter, a federal employee or a member of a labor union (to say nothing of being an actual member of CPUSA or one of its front organizations). In all of those cases, however, it's worth noting that really the federal government was mostly focused on its own employees, in terms of requiring loyalty oaths, holding internal investigations, and dismissing or forcing employees to resign. FBI investigations generally didn't get very far. Much of the backlash in, say, Hollywood, labor unions or academia was not the federal government, but senior members of those organizations collectively purging and blacklisting employees considered too sympathetic to Communism (or too liable to be influenced or blackmailed by Communists or Soviet agents).