If you ask the question now about some thought that occurred in the past - use "did".
"How do you know that"? As of this time, where did the knowledge come from?
"How did you know that"? Concerning a time in the past.
This is similar to - "How do you know that two plus two is four"? - "Because I remembered it".
"How did you know that two plus two is four"? "Because I added the numbers last week".