Obama expressed "American solidarity" with Denmark in a telephone conversation with Danish Prime Minister Helle Thorning-Schmidt on Monday, Xinhua cited from a White House statement.
In the first attack on Saturday, a gunman stormed into a building and opened fire at a meeting on "Art, Blasphemy and Freedom of Expression" in which the Swedish cartoonist Lars Vilks, known for his controversial portrayals of Prophet Muhammad, was participating.
A person was killed and three police officers were injured in the attack.
The second attack on Sunday was on Copenhagen's main synagogue. Another person was killed and two police officers were injured.
The gunman initially managed to flee, but was subsequently hunted down and shot dead by the police.
"The two leaders agreed on the need to work together to confront attacks on freedom of expression as well as against anti-semitic violence," the statement said.
Obama also welcomed Denmark's participation this week in the White House Summit on Countering Violent Extremism, it added.