Is the sentence “I sing the baby a lullaby” grammatically correct?
“I sing the baby a lullaby” is perfectly grammatical; in regard to objects and transitivity, it’s just like “Sing me a song.” It is only idiomatic in certain restricted, rather unusual settings, though. For example, it could be an answer to the question, “What is one of the things you do every night?” If you mean to answer the question, “What are you doing?”, it would be, “I am singing the baby a lullaby.” Your classmate was right to call you on it because it is so rarely called for. It doesn’t have to be “sang”, but that makes a more natural sentence of general application.