"공부 열심히 하세요" means "Study Hard".
but, "공부를 열심히 하세요" can not be used solely.
There should be a purpose to accomplish by studying hard.
so, it can be "대학에 진학하려면, 공부를 열심히 하세요" something like that.
means, "If you want to enter the university, you should study hard"