Wording in Ideas and Opinions: The man who is thoroughly convinced of the universal operation of the law of causation cannot for a moment entertain the idea of a being who interferes in the course of events — provided, of course, that he takes the hypothesis of causality really seriously. He has no use for the religion of fear and equally little for social or moral religion. A God who rewards and punishes is inconceivable to him for the simple reason that a man's actions are determined by necessity, external and internal, so that in God's eyes he cannot be responsible, any more than an inanimate object is responsible for the motions it undergoes. Science has therefore been charged with undermining morality, but the charge is unjust. A man's ethical behavior should be based effectually on sympathy, education, and social ties and needs; no religious basis is necessary. Man would indeed be in a poor way if he had to be restrained by fear of punishment and hopes of reward after death.
Variant: "It seems to me that the idea of a personal God is an anthropological concept which I cannot take seriously. I also cannot imagine some will or goal outside the human sphere" has been cited http://www.positiveatheism.org/hist/quotes/einstein.htm as a statement that precedes the last three sentences here, but in fact this is a separate quote from a 1947 letter Einstein wrote to Murray W. Gross, included in the Einstein and Religion (1999) section below (and in the letter the word used is "anthropomorphic," not "anthropological").
1930s, Religion and Science (1930)
Context: For any one who is pervaded with the sense of causal law in all that happens, who accepts in real earnest the assumption of causality, the idea of Being who interferes with the sequence of events in the world is absolutely impossible. Neither the religion of fear nor the social-moral religion can have any hold on him. A God who rewards and punishes is for him unthinkable, because man acts in accordance with an inner and outer necessity, and would, in the eyes of God, be as little responsible as an inanimate object is for the movements which it makes. Science, in consequence, has been accused of undermining morals—but wrongly. The ethical behavior of man is better based on sympathy, education and social relationships, and requires no support from religion. Man's plight would, indeed, be sad if he had to be kept in order through fear of punishment and hope of rewards after death.