When you are talking about one of the things being replaced, you use by
- A is being replaced by B
- A was replaced by B
When you're talking about the thing that is doing the replacement, you use with
- I will replace A with B
- she replaced A with B