Question: can afford infinitive or gerund?
Answer: Both are okay. Nevertheless, COCAE shows the verb afford + to + infinitive quite common similar to the examples you stated. I think the verb afford just like love and hate takes both - gerund and infinitive after it. They cannot afford to go out very often - used more frequently.