This refers to a specific historical event that the Hebrews knew well. Alternate translation: "when he was in Abimelech's house" or "when he was Abimelech's prisoner" (See: [[rc://en/ta/man/translate/figs-explicit]])
Here "in my mouth" refers to David speaking about Yahweh. Alternate translation: "I will always praise him out loud" (See: [[rc://en/ta/man/translate/figs-metonymy]])