The switch brings a high-profile Latino leader who is a rising star in Democratic politics into the Obama administration and moves a long-serving Cabinet member into the president's inner circle at the Office of Management and Budget.
Obama was set to make the announcement at 3:35 p.m. ET (1935 GMT) at the White House, flanked by Castro and Donovan, the White House official said.
"The President is thrilled that Secretary Donovan will take on this next role and believes that Mayor Castro is the right person to build on his critical work at HUD based on his work in San Antonio," the White House official said in a statement.
Donovan will take over from Sylvia Mathews Burwell, who is moving on to be secretary of health and human services. Burwell is awaiting confirmation by the Senate, and both Donovan and Castro must also be confirmed.
Donovan, 48, is highly regarded within the administration, and is seen as a low key, competent and hard worker who does not seek the limelight but has an eye for politics.
At OMB he is likely to be involved in talks with lawmakers to achieve a new budget agreement to ease the impact of automatic budget cuts known as the sequester.
"He's smart, quick, thoughtful, really knows what he's talking about and is interested in making government programs work better," said Robert Greenstein, head of the Washington-based Center on Budget and Policy Priorities.
"People think he's a straight shooter," Greenstein said, noting the trait would help Donovan in talks with Congress.
Donovan, who holds undergraduate and graduate degrees from Harvard University, was a leader within the administration in tackling the U.S. housing crisis, one of the triggers of the worst economic downturn since the Great Depression.
He was a chief negotiator in the historic $25 billion settlement reached with five of the nation's biggest banks and 49 state attorneys general to end a probe of abusive mortgage practices stemming from the housing bust.
Shortly after his re-election, Obama appointed Donovan to lead rebuilding efforts in areas that suffered damage by Superstorm Sandy, which ravaged the East Coast.
"Shaun Donovan is a consummate professional, thoughtful and analytical but also very politically aware," said Larry Summers, a former economic adviser to Obama, through his spokeswoman. "I expect he will make an excellent OMB director."
LAUNCHING PAD FOR CASTRO?
Castro, 39, would manage the $47 billion budget of the housing department at a time when there is evidence of renewed weakness in the U.S. housing market that is worrying policymakers and private economists.
Castro, the leader of the seventh-largest city in the United States, burst onto the national stage in 2012 when he delivered the keynote address at the Democratic National Convention, becoming the first Latino to do so.
The job will give Castro an opportunity to work on economic issues that are important to lower- and middle-class Americans, who make up a large part of the Democratic Party's political base.
Analysts believe the new position will raise the Texas native's profile further and serve as a possible launching pad for higher political office.
"This nomination will be good for Mayor Castro's political career and national profile because it positions him for either a future vice-presidential nomination or, in another Democratic administration, a higher profile cabinet post," said Henry Flores, a political science professor at St. Mary's University in San Antonio and a friend of the Castro family.
"Either way it will give Julian the bona fides for a future presidential run of his own," Flores said.
If confirmed, Castro would be a player in Washington's deliberations on how to make mortgages broadly accessible while minimizing risks to taxpayers. Officials also want to avoid setting the course for another housing bubble.
Castro would add another Hispanic face to Obama's Cabinet just as the party seeks to maintain its advantage with Latinos despite a failure to pass broad reform of U.S. immigration laws as Obama promised during his presidential campaigns.
The rapid rise of Castro and his twin brother Joaquin has been a compelling story in Democratic politics. After growing up in San Antonio, the two attended Stanford University and Harvard Law School before returning to their native city. Joaquin Castro is now a member of Congress.