You swear by something that you've found to be reliable: I swear by Vaseline for eczema. You swear on something that you value, like your mother's life.
The only similar example I can think of that uses "by" is the oath spoken by a witness, for example, in a legal case. "I swear by Almighty God that the evidence I shall give be the truth, the whole truth and nothing but the truth".
("Almighty God" can be replaced by the name of another deity or a holy scripture, depending on the religious persuasion of the person speaking.)