I did my homework and went to my grandmother's house. Before coordinating conjunctions we put a comma. Here we can omit the second subject. Do we need a comma before and or not?
I did my homework and went to my grandmother's house.
your sentence is correct.
you can ommit the subject of the second clause if it is the same. In this case, you don't have to use a comma.
I did my homework, and I went to my grandmother's house.
If you want to mention the subject again in the second part, you have to use a comma before 'and'.
NOT A TEACHER
(1) Teachers Fivejedjon and Mohammadhelmi have given us excellent answers.
(2) May I add a few comments, for I, too, am interested in your kind of question.
(3) When you get time, please study the differences between simple sentences and
compound sentences.
(4) I + did my homework and went to my grandmother's house.
(a) One subject ("I") and two verbs for the one subject ("did" and "went"). So we
call that a simple sentence.
(b) In your sentence, you want to express the idea that "doing" and "going" were
equally important.
(5) Some people feel that it would be "better" to use two sentences connected with
"and" (a so-called compound sentence):
I did my homework + I went to my grandmother's house.
That is, " I did my homework, and I went to my grandmother's house."
When you use two sentences, some people feel that you are more clearly
showing what happened after you did your homework.
NOTES:
(a) I agree that it is preferable to use a comma in that compound sentence.
But, as Teacher Fivejedjon taught us, it is not absolutely necessary.
(b) I wish to credit Harper's English Grammar by John B. Opdycke, Ph.D., for the
semantic differences between simple and compound sentences.