Joint pain is generally the result of tight muscles that surround the joint and not a result of something within the joint itself.
For knee pain depending on where it is localized you may need to stretch out your quads more. If you feel pain or a strong pulling at the top of the knee or on either side when your knee is in a deep bend such as in virasana then it is most likely your quads that are tight and pulling on the patella tendon that attaches onto the bottom of the quad muscle. If you feel pain under the knee cap when you bend then it may be something else like patella femoral syndrome, where the underside of the knee cap becomes rough from an imbalance in the strength of the quads and improper tracking of the knee cap.
In regards to the ankle joint it is important to strengthen and support the ankle and always keep it in a neutral position during all asanas. This means that the toes are drawn back towards the shin slightly and there is no sickling from side to side. Muscle pain can be from a number of different things. A good rule of thumb is if you have pain 24 hours or longer after your practice, not soreness but pain, then there has been misalignment during your asana practice. Begin to pay close attention to your alignment in every posture, attend a class that focuses on alignment and ask questions of your instructor if anything does not feel right during or after a class.