Painful sex

How did it take you until sex was no longer painful? Is there anything I can do to make it feel better?