They’re willing to help students, but mightn’t be required to obey.
The house-elves seem to be always very willing to serve the students - whenever students go to the kitchen asking for food, they’re always happy to provide it. They definitely seem to consider serving the students part of being Hogwarts house-elves, as they bow and treat them with respect.
“No chance of more of those éclairs, is there?’ said Ron, who was looking around at the beaming and bowing house-elves.
‘You’ve just had breakfast!’ said Hermione irritably, but a great silver platter of éclairs was already zooming towards them, supported by four elves.”
- Harry Potter and the Goblet of Fire, Chapter 28 (The Madness of Mr Crouch)
However, it’s not clear if they’re actually obligated to obey the students. It seems like they would anyway in the vast majority of situations. However, it’s not clear if they’re required to, or if their service of Hogwarts means that the students would have a level of control over them included in the enchantment of them. It seems likely that they’d only be ‘magically forced’ to obey the headmaster, since he or she would be their master, though they’d still be helpful to the students.
“Can’t house-elves speak their minds about their masters, then?’ Harry asked.
‘Oh, no, sir, no,’ said Dobby, looking suddenly serious.‘’Tis part of the house-elf’s enslavement, sir. We keeps their secrets and our silence, sir, we upholds the family’s honour, and we never speaks ill of them – though Professor Dumbledore told Dobby he does not insist upon this. Professor Dumbledore said we is free to – to –”
- Harry Potter and the Goblet of Fire, Chapter 21 (The House-Elf Liberation Front)
Further indication that they’re not obligated to obey the students is that they’ve actually gotten offended at Hermione’s suggestions that they should all want freedom and treated her differently because of it. She offends them to the point where they push her, along with Ron and Harry who hadn’t done anything to upset them, out of the kitchen. Though the house-elves still give Ron and Harry their extra food, they force them out and slam the door behind them.
“The cheery smiles had vanished from the faces of the house-elves around the kitchen. They were suddenly looking at Hermione as though she was mad and dangerous.
‘We has your extra food!’ squeaked an elf at Harry’s elbow, and he shoved a large ham, a dozen cakes and some fruit into Harry’s arms. ‘Goodbye!’
The house-elves crowded around Harry, Ron and Hermione, and began shunting them out of the kitchen, many little hands pushing in the smalls of their backs.”
- Harry Potter and the Goblet of Fire, Chapter 21 (The House-Elf Liberation Front)
It’d be bad planning to have the house-elves always required to obey the students. Having students be able to command house-elves could let them order the house-elves to do a variety of things that the staff absolutely wouldn’t want, and wouldn’t always be able to find out about and overrule the student so stop the house-elves from doing them. Students could, for example, have a house-elf steal them the answers to their next test, put worms in their enemy’s bed, and even have them poison the food. Harry sometimes gives Dobby orders, but this may be a special case, as he greatly respects Harry - he may simply choose to obey Harry because he likes him so much.
“Dobby – this is an order – get back down to the kitchen with the other elves and, if she asks you whether you warned me, lie and say no!’ said Harry. ‘And I forbid you to hurt yourself!’ he added, dropping the elf as he made it over the threshold at last and slammed the door behind him.
‘Thank you, Harry Potter!’ squeaked Dobby, and he streaked off.”
- Harry Potter and the Order of the Phoenix, Chapter 27 (The Centaur and the Sneak)
However, even Dobby is forced to obey Umbridge and punish himself for disobeying her, since he had to punish himself for trying to tell Harry that Umbridge knew about Dumbledore’s Army.
[fan-fiction]
? The starting point is a fan fiction, but the question itself is about official canon ...