Obama said he and Kennedy had talked earlier in the week about Obama doing the speech.
"Considering what he's done for me and for our country, there's nothing I wouldn't do for him," Obama said in a statement. "So I'm looking forward to standing in his place on Sunday even though I know I won't be able to fill his shoes."
Kennedy was diagnosed this week with a malignant brain tumor, which was discovered after he had a seizure at his home last Saturday. He was released Wednesday from Massachusetts General Hospital and has been recovering from his biopsy at the Kennedy family compound on Cape Cod.
Kennedy's spokeswoman, Stephanie Cutter, said Kennedy accepted Obama's offer to help "knowing it would be an historic opportunity for the school and all those attending," including his stepdaughter, Caroline Raclin, and his son.
"He's enormously grateful to Senator Obama and the support he's received from all of his colleagues this last week," Cutter said.