How do I store a question-and-answer combination for machine learning?
Typically, people do not use one hot encoding as it takes up a lot of space (vocabulary size explodes) and is difficult to learn as well. Instead, they project words into a high dimensional vector space where each dimension represents some sense or direction.

For example, if you consider the words red and green - they are opposites in the context of a traffic light but are similar in the sense that they are both names of colours. A vector representation of the word will incorporate such relations by having similar values for some dimensions and different values for the others.

For more details, you can read this paper.

As for your next question, standard practice is to limit the sentence length through truncation and pad smaller sentences with additional 0 vectors.