Many English passive sentences do not contain BY + Agent after the verb. In fact, it has been estimated that 80% of passive verbs don't include the agent, so a basic rule would be to omit wherever possible.
There are cases where its use would be regarded as wrong or, at best, uncomfortable:
My wallet was stolen by someone.
Here the use adds no information other than the fact that the thief was human. It is completely unnecessary and sounds wrong. The same is true of examples where the subject is too obvious (I was born by my mother).
There are examples given in books that are correct but very limited:
Hamlet was written by Shakespeare.
This sentence is correct, but the second other information is put into the sentence, it starts to sound stilted. If the date or reason were added, then the agent would probably be best omitted. In the example given, it is necessary because 'Hamlet was written.' makes little sense as a stand-alone sentence.
Many car accidents are caused by alcohol.
Here the agent is necessary as it adds something to the sentence and there would be no meaning without it. In cases like this, where the agent is essential to create the meaning, it must be included. Where it adds little or nothing, it is better to leave it out.