Sex and Marriage

When did it become okay to have sex outside of marriage, let alone children? Almost everything I see on here doesn't include marriage and it makes my heart grieve.