Use the phrases "I could have sworn..." when you were really sure that you knew something, but then you find out that you were wrong.
For example, imagine that you're telling a story about a trip that you took a long time ago with your friend. But then your friend says that she doesn't remember it:
A: I don't remember that at all. It must have been someone else.
B: Really? No, I could have sworn it was you!
You were really sure that she was on the trip with you, but now you find out that maybe she wasn't.